A file must have the appropriate permissions (read, write, or both) for the corresponding operation being performed on it.
When a file is created, the default permissions (if the umask setting is 000) are both read and write for user, group, and other. You can turn off individual permission bits by changing the umask setting before you run the program.