Hello Martin and welcome to the ArtRage forums
OK, so I’m not an expert on AR scripting (or any other kind of scripting for that matter!) but I shall tell you what happens with your example script for me;
1: Ran it as is. Unaltered.
Same as for you, it stops after 2 exports with the same error message.

2: Using BBEdit text editor I changed only your name ‘martin’ in all the file export paths to my name 'mark'.
Then used Save As…
Ran the new edited script which played to end of the script without stopping on multiple tries.
Total of 8 exported layers with each run.

Observations:
Although an export path and file type are specified in the script these are actually ignored with only the Export Window being triggered which will use the same settings as the last export used.
The last line calls for another export, No: 9 but it never seems to do it as I consistently only get 8 exports in total.

Why just changing your name to mine in the export path made it work correctly I have no idea!!!
Why is there no export 9???
Make of my experiments what you will!