write output to file