The while-loop is executed in a subshell, so changes to the variable inside the while-loop won't affect the external variable.