Files handling Operations in TCL

r

Open the file for reading only; the file must already exist. This is the default value if access is not specified.

r+

Open the file for both reading and writing; the file must already exist.

w

Open the file for writing only. Truncate it if it exists. If it doesn't exist, create a new file.

w+

Open the file for reading and writing. Truncate it if it exists. If it doesn't exist, create a new file.

a

Open the file for writing only. The file must already exist, and the file is positioned so that new data is appended to the file.

a+

Open the file for reading and writing. If the file doesn't exist, create a new empty file. Set the initial access position to the end of the file.