sm said:
How to "Insert" (not append) new text segment to an existing text file?
Assume that we have text file as shown below;
Elvis
Sofia
Kylix
BCB--> How to insert here?
Atten
BuilderX
Roma
Together
Cairo
This has nothing to do with the language. Open the file for reading,
open another file (new one) for writing. Begin reading the first one
and writing to the new one until you hit the spot where you need to
insert something. Now, write what you need inserted. Once done, go
on with "copying" the contents of the original file. Another possible
solution is to read the entire contents of the file into some memory
structure, insert what you need into that structure, then write that
structure out to the same file again (after re-opening it for writing).
V