You shouldn't have two variables with the same name.

The variable year inside the while loop, if it even allows it to be valid at all, which I'm not sure about, as it has the same name as the...