Before you can use the (rules) line numbers you first have to fixate them in a script.
print without-paging; # to have a correct location of numbers in the table
Then determine the dynamic lines to skip.
:local dynamicLines [:len [ find dynamic]];
:do { add place-before=($dynamicLines) action=..... }
The lines start a 0 (zero) and dynamicLines gets the number of lines. So you don’t have to add a extra line-number to use place-before. It is already the correct line.
Bit rusty on this so I had to look it up. Have fun.