added write_to_file