Fix some error messages
Remove a redundant function call
Don't fail on file_not_found if that's what you're checking for
Factor out a common expression
Remove unused variable