added code that outputs results to a csv