Script help

So I created a script that creates 2d views and turns them into blocks for certain files that I pick, but the script will only run a certain number of files before it stops. Since I have a almost 300 files I need to run it on, it sucks to have to start it over again. Can someone with more programming experience than me take a look and see what I could do to improve it or make it run longer before quitting. Thanks (2.9 KB)

Since the script is specific to certain layer structure I am working with, here are some test files to run it on if interested. (3.9 MB)