added page loop to csv_writer