The problem isn't your IDE - it's just a fancy editor.
You could have written the same code in notepad and compiled from the command line, and you'd still have the same problem.
It isn't your compiler either, or for that matter your OS.
It all boils down to the standard library implementation that your program is linked with, and your choice of text file format.
For example, I took seeplus's code, compiled it with C::B on Windows.
If "test.txt" is a normal Windows file with CRLF line endings, then I get the results you first posted.
If "test.txt" is a Unix file (which is dead easy to achieve using notepad++), then I get the results you expect.
Same everything except for the choice of line endings on the text file, and completely different answers.
The basic problem is seek/tell is very poorly specified for text files (it's probably UB).
Especially when those text files undergo CRLF <-> LF transformations on input and output.
You could try opening the text file in binary mode ->
https://en.cppreference.com/w/cpp/io/ios_base/openmode
But you'd end up with a file containing both CRLF and LF line endings, since it effectively turns off all the text mode translations (specifically your
inOut << '\n';).
Linux doesn't have a problem because there is no distinction between text or binary, as lines in text files just end with \n.
Mixing up (seek/tell)g with (seek/tell)p probably isn't helping matters either.