Insert line into file

Is there a way of inserting a line at a specific line number in an existing file without rewriting the entire file?

for example. If I have a file and I want to insert a line of text that I want to be the new line 2 of that file.

well specfically, I am creating an XML doc use the xmlelement::createdocument and now I want to add a XML style sheet entry into line 2.

I’d just load it all into a StringArray with StringArray::addLines(), add the stuff you need, and write it all out again.