s/open/file/g
make file handling more idiomatic
DRY some file accesses
remove extraneous parens