You could try manually changing the ID when adding a new link. The script should then write the correct figure to linksid.txt and start working correctly (assuming there's not a configuration problem somewhere).
Be aware that clicking on "Add Link", but not actually adding a link can still advance the link counter.
Be aware that clicking on "Add Link", but not actually adding a link can still advance the link counter.