Write data to CSV file.