Set number of PVi_m cards inside and outside of loop

...so that it has a correct value even if the loop ends early because an
error occurs.