how can I create file every 2K?

hello ,
I want to read data from the router and save it into one file - this I know how to do .
it there any way to tell him that if the size is bigger then 4K to create a new file , and start save the data into the new file?

Thanks ,