Because the upper limit is evaluated at the beginning of the execution when r = 7. If you want the loop condition to be evaluated every time the loop iterates, you need to use a while loop. See even if you did something like this:
You would still get 7 iterations. However now we are overwriting the iterator so you would only get 5s.