I use the same camera (Powershot A610) with 2 SD cards.
One card with CHDK 0.9.8-758 and the script that works.
A second SD card with CHDK 0.9.9-1054 and exactly the same script which does not work.
Indeed, with this second card, there is an error message: uBasic:72 Parse err
I thought that 72 were a line number and I opened the script with Notepad++ which shows the line numbers.
Line 72 corresponds to the line which you had indicated previously.
I modified this line (endif deleted) and after the error message was: uBasic:105 Parse err
Line 105 is: else if z<c then z=z+1
I modified this line (rem else if z<c then z=z+1) and after the error message was:uBasic:106 Parse err
Line 106 is: else if z>c then z=1
I also modified this line (rem else if z>c then z=1) and after the script finished without error message.
Of course, now the script does not the job.