Exporting query to .csv file