Add function to write the list of image files when button 4 is pressed.