Wrap file open in try-except

In setenforce(), similar to getenforce()
Merge pull request #10501 from holmboe/enforce-open-except

Wrap file open in try-except