Now includes functionality to output results to CSV.