Adding to a File NOT Overwriting...
Posted: Mon Dec 27, 2004 6:39 am
Hello,
In my script I am using r+ to read the file, and the write to it also. However, this places the pointer at the start of the file, so it overwrites anything that overlaps the new content that is being written.
My question is this. Say we have a document like this, in a txt format:
And the user fills in a form that will upload this to that txt format:
How do I make it so that when the new data is written, the final result is this:
All I need is to know what mode to read/write in, and what I need to actually write. For example, making a copy of the file, and including it in the writing string (I tried this, but no results.).
Thanks
In my script I am using r+ to read the file, and the write to it also. However, this places the pointer at the start of the file, so it overwrites anything that overlaps the new content that is being written.
My question is this. Say we have a document like this, in a txt format:
Code: Select all
Apple Orange Pear Grape
Ford Citroen TVR FerrariCode: Select all
Pepsi Fanta Sprite 7-UpCode: Select all
Pepsi Fanta Sprite 7-Up
Apple Orange Pear Grape
Ford Citroen TVR FerrariThanks