Are you showing the full 15 898 lines?
You can insert a special character on each line like word does for paragraphs? And remove it later?
But text isn't the best option, you should be using an array and build it from there.
Is it an online book? because text object has limits in place for a reason. You don't need to load it all it one go or rather you shouldn't.
You are going to have performance issues I would imagine?
Anyways, google how to make a text editor like word etc. They have the formula's you need, and how to hack up a piece of text.
My guess you will be using RegexMatchCount /search/replace/match - lol - good luck.