write output to csv