Read/write
There are three modes on files:
- read only: The data in the file can be read, but not modified.
- read/write: The data in the file can be read and modified.
- write only: The data in the file can be modified.
Each of these are useful in their own way.
Read Only
Read only is useful when you want to access but not modify the data. It is often the case that you want to look but not touch.
Write Only
This is useful for logfiles and output files. Sometimes you aren't interested in what was already in the file. You only want to say your piece and move on.
Read/Write
It is pretty rare that you want to both read to and write to a file. This is only the case when you want to make a specific change, or record a small update.