>Kindly let me know of alternatives of how I could solve this problem.
You're not actually appending to the file, you're appending to lines in the file, which amounts to inserting into the file. Unless you're using a system with record oriented files, your two best options are probably the following:
- Store everything in memory until you're ready to save, then overwrite the file.
- Write a new file with your changes, then replace the original file with the new file.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,483
Solved Threads: 1,407
Skill Endorsements: 54
if you want the capability of being able to shoot yourself in the foot, you can try
3. use fixed width records and one or more of "fseek", "ftell", "fsetpos", and "rewind" to manipulate the filestream and edit it in-line.
personally, though, i would go with either one of Narue's #1 or #2. manipulating inline can be fun, but ultimately is just asking for trouble.
.
jephthah
Posting Maven
2,592 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
Skill Endorsements: 5
Question Answered as of 3 Years Ago by
Narue,
jephthah
and
uskok