set_standard_filenames has to be called after the while loop, so the standard filenames will always be set. Other than that it's really good.