For streams that are both read and written, it is important to note that it is not possible to switch
arbitrarily between reading and writing.12 Once you start to read or write a file you have to perform
a seek operation, potentially to the current position, to switch from reading to writing or vice versa.
The only exception to this rule is if you have read until end-of-file. In this case, you can continue
writing characters immediately. Violating this rule can lead to all kinds of strange effects.