It's certainly not the best. This checks if the read failed, which could be for many reasons.
It's usually a good enough way to do it.