poly curve problem

I got an old script for making some spline poly curve

but there is a bug at then end

can someone help to make it work again

here is file with script inside

thanks for any feedback
happy bl

Attachments

Znurbs-test1.blend (784 KB)