If statement running while not ture

In the following code, the while statement is true while the if statement is false, but the Serial monitor still outputs "You are correct!", but I'm not sure why (very new to Arduino)

 while(chosenLED == 8) 
    if(digitalRead(2) == 1)
      digitalWrite(8, HIGH);
      digitalWrite(8, LOW);
      Serial.println("You are correct!");

And how do you know the if() statement is false? The only sure way to know is assign the value read to a variable and print it out. It may surprise you. Have you properly delcared pin 2 as in INPUT? Is there a pull-up or pull-down resistor connected to it? Are you enabling the internal pull-up resistor as an alternative? If it is floating (not specifically high or low) then it could read either state.

Post a complete sketch that exhibits this behavior, not just a snippit.

If ‘chosenLED’ was 8, how do you ever get out of the ‘while’ loop?

You can safely assume if, while and suchlike work completely correctly! You are correctly using == for equality test, so it must be the case digitalRead(2) is returning 1.

The only very unlikely way code could be getting this wrong is if your program uses all the available memory and goes haywire as a result, but as you've not posted the entire program there's no way for us to check this.

MarkT: You can safely assume if, while and suchlike work completely correctly

Wish I had $$ for every time a newbie posted about some core feature of the language not working or a shortcoming with "the compiler". Yes, it happens occasionally. But, the more experienced a coder you become, the more likely you are to suspect that you've done something stupid.