Fixed file descriptor handling when the variable is nil