Check the return value of fgets