Check the return code from close() and output an error if it