Created method to write CSV file.