implemented write_output_file