Turning for into while, which is syntactically favorable in bash