What most the responses so far seem to have missed is that the cast of the in-ram spliting and joining of records, pales into insignificance when compared to the time required for the read-a-record, write-a-record flip-flopping of the read head back and forth across the disk.

There are two possible ways to speed up your processing:

Overlap the spliting & joining with either the reading or the writing (or both).

This can be achieved by using two or more threads or processes.

Read and write larger chunks of the file to minimise the number of seeks the read heads need to make.