Replace reverse-'while' with 'for' loop

Fix gh-1
1.0.1