fix the output-to-file part