write output file