Fixed error checking error status

Error status was not correctly checked. Thanks Inge van Bremen for the
fix!