close the filedescriptor earlier if there was a problem
indentation