Exit properly if opening file fails