Resolved the issue with writing to CSV files.