Improve CSV file generation