Cleaned up example for write_to_file