Write CSV data to file