Save result of a query to CSV file