timed_write_to_file