writing the output file