BUG: GH3163 fixed to_csv with a boundry condition issue at the chunksize break

closes #3163