generate_data closes file identifier