reduced to one csv, added header row, moved csv creation out of loop