in reply to Re^3: opening file for editing
in thread opening file for editing

you can understand in this way:
The file name here is where you save your work. 
( you use close() to save your file )
So it doesn't matter the file has data inside or not. 
ONLY the data in the handle will write to your file.
ie. This ">" is an overwrite, if you are opening an existed file

So, since you are open a file for WRITE, so it couldn't READ, while you read
nothing, so you write nothing. End up, you harvest an empty file

Replies are listed 'Best First'.
Re^3: opening file for editing
by Anonymous Monk on Oct 09, 2011 at 11:45 UTC
    ok i got it, i just wanted to know any way i can open already existing file change it on the fly

      No, that's not how editors work. Read from original, write to a new temp file. When the writing is complete and successful(!), rename the temp file to the old name. Typically you don't want to wipe out the original until you are sure you have a good replacement for it.

      --Dave