use with statement for file operations (where appropriate)