successfully iterating over all the data. need a terminating condition and filewriter