change output_file's logic