added a perror
check rval of close