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

well, why is the file going blank if i use > even though the file exists and has contents

Because that is what > means, see open

Replies are listed 'Best First'.
Re^2: opening file for editing
by exilepanda (Friar) on Oct 09, 2011 at 10:47 UTC
    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
    
      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