fix bug in save_record_to_file()