Use "open()" to be compatible with Python 3

I'm not sure how to actually get to this branch of the code. (If I did, I would add a test case.)