added CSV file writer functionality