Your main problem is that you're not reading a new value each time the player get the answer wrong. You need to re-assign the value of "YesNo" within the while loop with YesNo = readLine. At the start you can initialize it to null with var YesNo = _
Also you might find using pattern matching is neater than if-expressions. e.g.
Should you succeed, you next task is to re-write it without using any mutable state (i.e. no vars, only vals)...
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
a bit of art, as a gift, that will fit in a stocking