Check access to a file before opening it

Detect and handle file operation errors

Do not reference file handles after the file they have been associated with is closed

Avoid OS specific syntax for file paths

Do not remove or rename open files

open files with as few privileges as necessary