if your file reads like this

Line no 1
Line 2 is bigger than 1
Line 3 is small.
then you have no choice but to write the whole file again.

but if all of your lines are of same length then you can use
QTextStream::seek();