A for loop visits each item in a list. A while loop repeats while its condition succeeds and therefore needs a change that eventually makes the condition false. Check the first and final iteration when you read a loop.
Off-by-one errors often create one extra output row or omit the last one. In these tasks, preserve the list order and print one record per iteration. A fixed list has a known set of items; a counter-based loop needs an explicit boundary.
Update a counter with n=$((n + 1)) inside the while body so it can reach its stopping boundary. In a for list, quote any item containing spaces. Put output redirection after done to capture the whole loop once; using a replacing redirection inside the body would overwrite earlier iterations' output.