Inky frame writes jpg once then crashes the next time with an OSError: [Errno 5] EIO error

Am trying to get Inky frame to display a sequence of images with a delay in between.
The following code writes the first image fine, but the second time gives:

Traceback (most recent call last):
File ‘’, line 39, in
File ‘’, line 34, in show_jpg
File “common/sdcard.py”, line 252, in readblocks
OSError: [Errno 5] EIO
Have tried lots of variations, based on other examples, but no go.
Any help appreciated

===========================

from picographics import PicoGraphics, DISPLAY_INKY_FRAME
from jpegdec import JPEG
from machine import SPI, Pin
import sdcard
import uos

image_list = [‘sd/image01s.jpg’, ‘sd/image02s.jpg’, ‘sd/image03s.jpg’, ‘sd/image04s.jpg’, ‘sd/image05s.jpg’,
‘sd/image06s.jpg’, ‘sd/image07s.jpg’, ‘sd/image08s.jpg’, ‘sd/image09s.jpg’, ‘sd/image10s.jpg’,
‘sd/image11s.jpg’, ‘sd/image12s.jpg’, ‘sd/image13s.jpg’, ‘sd/image14s.jpg’, ‘sd/image15s.jpg’,
‘sd/image16s.jpg’, ‘sd/image17s.jpg’, ‘sd/image18s.jpg’, ‘sd/image19s.jpg’, ‘sd/image20s.jpg’,
‘sd/image21s.jpg’, ‘sd/image22s.jpg’, ‘sd/image23s.jpg’, ‘sd/image24s.jpg’, ‘sd/image25s.jpg’,
‘sd/image26s.jpg’, ‘sd/image27s.jpg’, ‘sd/image28s.jpg’, ‘sd/image29s.jpg’, ‘sd/image30s.jpg’,
‘sd/image31s.jpg’]

set up the SD card

sd_spi = SPI(0, sck=Pin(18, Pin.OUT), mosi=Pin(19, Pin.OUT), miso=Pin(16, Pin.OUT))
sd = sdcard.SDCard(sd_spi, Pin(22))
uos.mount(sd, “/sd”)

set up the display

display = PicoGraphics(display=DISPLAY_INKY_FRAME)
j = JPEG(display)

def show_jpg(this_image):
j.open_file(this_image) # Open the JPEG file
j.decode() # Decode the JPEG
display.update() # Display the result

show_jpg(image_list[0])
show_jpg(image_list[1])
show_jpg(image_list[2])