1The opening modes are exactly the same as those for the C standard library function fopen(). The following text in provided by the BSD fopen manpage (see https://www.freebsd.org/):

The argument mode points to a string beginning with one of the following letters:

“r"

Open for reading. The stream is positioned at the beginning of the file. Fail if the file does not exist.

“w"

Open for writing. The stream is positioned at the beginning of the file. Truncate the file to zero length if it exists or create the file if it does not exist.

“a"

Open for writing. The stream is positioned at the end of the file. Subsequent writes to the file will always end up at the then current end of file [...]. Create the file if it does not exist.

An optional “+" following “r", “w", or “a" opens the file for both reading and writing.