fstream pointer location is fubar

So, my code is convoluted and ridiculous so I won't post any code snippets. But to put it simply:

My goal is to insert some text into a text file, in between what's already there. The only way I could find of doing this that I could comprehend was to find where I want to write into, read everything in the file up to that point, write in a temp file, append the data I want, read everything in the previous file from where I left off, append that to the temp file, and finally read the entire temp file and overwrite the actual file.

and I can, but when I use tellg() to tell me where the get pointer is for use with both where to start reading from and how much to write, it's just fubar. I eventually figured out that it was incrementing the pointer twice for every new line, and I did a bunch of crap to count how many lines and subtract that amount to make it accurate. Which worked at the time, but now having continue to expand on it, it's not, and I've entrenched myself deep in confusion.

So, this is probably not enough information, but can anyone help me?
Topic archived. No new replies allowed.