...and it actually was, if you keep it simple without any unnecessary foolishness 🤷♂️
Not really. My previous implementation was really ugly (I mean, really ugly). And since the school requires us to code the function in the exam, I figured best to give this a second try while also going for the bonus - which is very easy.
There is a slight compromise in the definition of the static variable - I'm assuming there are no lines longer than 4096 chars.