Mode is one of
a = append open for reading & writing, create if doesn't exist
r = read open for reading, fail if doesn't exist
u = open open for reading & writing, fail if doesn't exist
c = create open for reading & writing, fail if it already exists
o = overwrite open for reading & writing, overwrite if it already exists
Additionally, all modes fail if the file can't be opened. On systems
that support flock, 'r' fails if a shared lock can not be obtained; the
other modes fail if an exclusive lock can't be obtained.