Need a small fix InDesign Applescript

Hi,
I wrote a tiny script to turn any empty text boxes in an ID doc to Unassigned content.

tell application "Adobe InDesign CS3"
	tell active document
		set myTextframes to every text frame
		repeat with i from 1 to count of myTextframes
			if contents of text frame i = "" then
				set (content type) of text frame i to unassigned
			end if
		end repeat
	end tell
	end tell

It works, except it always displays a message: Adobe InDesign CS3 got an error: Can’t get contents of text frame (number) of active document. It doesn’t matter to me, since I know that the script works. But someday I’d like to share this with others. Any idea why I get this error?

AppleScript: 2.11
Browser: Firefox 3.5.8
Operating System: Mac OS X (10.5)

Hi. You’re looping through indexes and then altering their state; at some point, the item ceases to exist. You could avoid the error by looping in reverse, but this can be expressed without looping.

Without looping through the text frames you can use the following:

tell application "Adobe InDesign CS3"
	tell active document
		set (content type) of every text frame whose contents is "" to unassigned
	end tell
end tell