Fix write_to_file().