converted while to for loop

replaced truth statement with iterator, range & iteration