Don't close the file descriptor before the error message has been retrieved