in reply to Openind file for read+append

Opening a file for appending positions the file pointer at the end of the file. If you also want the read its contents, you have to seek to the beginning (or wherever you want to) before reading. (The OS maintains only one file pointer per file handle, not one for reading, and one for writing.)

Replies are listed 'Best First'.
Re^2: Openind file for read+append
by MidLifeXis (Monsignor) on Feb 08, 2012 at 18:40 UTC

    ... and seek to the end before writing again.

    --MidLifeXis

Re^2: Openind file for read+append
by jaldama (Acolyte) on Feb 08, 2012 at 18:46 UTC
    Thanks @eliya , I didn't realize that!