Fixed bug for the output file