It just keeps doing that. Eventually it will pick a blank line or "User:" or a special word and that stops the loop.
If you're thinking that this process doesn't resemble how anyone writes a novel or a computer program, you are right. It's literally the same as mashing the three predictions on your phone keyboard randomly.
The main difference is that the LLM is large (10,100,200GiB) and your phone keyboard is not large (just a few MiB)
And that's why you don't need to compete with ChatGPT. It can't plan, count (without counting out loud), reason logically, reason geomerically, experience anything, be inspired, feel emotions, or even know what words mean.
It also suffers a lot of problems based on the way it works. For example if it randomly picks an old timey word, that increases its probability estimates for old timey words the next time it goes around the loop which means it will eventually pick a second old timey word.
That will make it estimate old timey words even more likely and soon it will pick a third! By the end of a paragraph now it's fully old timey.
So the moment you or it start hinting towards a certain style or voice it will just amplify that until it's stuck.
See how when I drop the style it has already gotten stuck in Victorian mode so it just keeps going that way?