in reply to Split very big string in half

I would very-quickly agree with the following sentiment:   “So, you have a ~3 million character file.   (So what?)   Why do you feel the need to slurp it?”

The short-answer, I think, is:   “you don’t.”   :-)   Simply treat it as the file that it naturally is.   seek() to the midpoint, less (say), 10,000 characters, and read 10,000 characters.   Look within this string for the end-tag that you seek.   Once you find it, you can effortlessly calculate the file-offset where it appears, and that’s the split-point that you’re looking for.   Exactly the same memory-frugal logic could be applied to a file of any size.

You do not need to use a big string ... to split a big file.