Add method to write output to a csv file