error handling in xfgets