Thanks, Sanctus Germanus. The code turned out not to be the problem. After repeatedly failing on my "test" computer, I ran my script on other computers and it worked.
I can't tell exactly what was wrong with the test computer. I can tell you it cost me about a week-and-a-half of experimenting before I found out that the script works on the four or five other Macs I've tested it on!
Again, thanks. The responses I've received throughout this forum have been very helpful in my scripting project.