[BUGFIX] Prevent infinite loop
Merge pull request #472 from bjo3rnf/forawhile

[BUGFIX] Prevent infinite loop