Sep-01-2020, 03:14 PM
The "wb truncates" means that opening a file with "w" (the "b" doesn't matter for this) resets the file to empty. Truncates is not a great choice of words because we are used to "truncate to a value" or "truncate to a precision". Here it means "truncate to 0 bytes".
There is only one place you should ever write to a file, after the end. You can do this with an empty file, or with a file that contains values. You need to be really careful when trying to write anywhere else.
There is only one place you should ever write to a file, after the end. You can do this with an empty file, or with a file that contains values. You need to be really careful when trying to write anywhere else.