Shortest path in NL algorithm, need help to understand
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$.