Simplify the logic in open_file() some more.