Will the code run again while it was still in the while loop
Once you reload your game everything resumes at the exact point it was. Just like if the player had never saved/reloaded. If you algorithm was on the second instruction on line 27 for the 137th item, it will resume at the exact same point.
Now, you need to understand that anytime you use HasKeyword, GetAt, GetNthForm, or other native functions, your script is paused for one frame (this does not happen for "non-delayed" native functions and non-native functions). Your code does nothing during that time, it just waits uselessly, it does not consume CPU. So, basically, there are two ways to proceed:
* Reduce the number of native calls, this is what JustinOther suggested and his solution saves you from testing keywords. Since you were testing up to 12 (6 on average) of them per form out of up to 14 (8 on average) instructions per form, your code will be up to 7 times faster (4 times on average), with one item performed every 2 frames (GetAt + SetName). Chesko's suggestion to use arrays would have saved you one call (GetAt) but I don't think it is worth the hassle.
* Split the job across many objects: you could for example have one quest for armors, one for potions, etc. If you have 12 quests, you will process 12 times more items per frame.
The good news is that once you understand this, everything is pretty predictable. Count the number of native calls required, the number of items and you can know in advance how long it will take. If you think it's not fast enough, you can divide further.
Upon clicking those links and reading the contents, my brain cooked and turned into a nice crispy burnt black and then all the mucus in my skull liquified my previously choarcoal'd brain and made it ooz out of my ears. Papyrus was definitely made with you people in mind.
Moving to a "real" programming language was a good idea from Bethesda but the concurrent architecture of Papyrus is very hard to deal with. There are reasons for that, though, related to the strategy used by Bethesda to exploit every core of your CPU, and concurrency is always painful. Now I would have liked more tools to deal with those problems (like a granular control over locking, etc). And I wish that in TES6 they will move to a model where object is an agent and all cals are asynchronous unless specified otherwise, with a richer language.