From APUE
When a file is opened for reading and writing (the plus sign in the type), two restrictions apply.
• Output canno
When working with a FILE
stream, there is a single internal buffer used when either reading from or writing to the file.
When switching between reading and writing, that buffer must be cleared before switching modes, otherwise data loss could potentially occur. Each of the operations mentioned above perform the required flushing of the buffer.