More efficient handling of !file.good().