Handle file opening error conditions better.

Before we didn't always close our file and checked completely the wrong thing.
They were a duff few lines.