Shortest path in NL algorithm, need help to understand https://people.eecs.berkeley.edu/~luca/cs172-07/solutions/sol8.pdf

I'm checking those solution and i'm having trouble understanding the proof that shortest path belong to NL (2.a).

So being Shortest path = {(G=(V,E), k, s, t) | shortest path from s to t in G has length k}  and rk-1 being the number of vertices reachable in k-1 steps, the proposed algorithm is

d ← 0
flag ← FALSE
for all w ∈ V do
    p ← s
    for i ← 1 to k − 1 do
        non-deterministically pick a neighbor q of p
    if p = w then
        d ← d + 1
    if w = t reject
    if w is a neighbor of t then
    flag ← TRUE
if d &lt; rk−1 reject
if flag then accept else reject


In a line it does "non-deterministically pick a neighbor q of p" but q it's never used. Where and how it's q used?
What is probably meant is that the chosen vertex is substituted back into $p$. This way when the for loop is done, $p$ contains some vertex of distance at most $k-1$ from $s$. Note that comparing the counter $d$ to $r_{k-1}$ makes sure that you went over all the vertices of distance at most $k-1$ from $s$.