write output to csv file