How To Add Dynamic Variable To A List

I’m running into a problem where I have a dynamic variable that changes through each iteration not being added to a list. Basically if it hits an error in a given invoice it webscrapes the invoice number and logs it as a variable, and then tries to add to collection in the list. Rather than adding each new value in the list everytime the variable changes, the list only has the last value the variable was assigned. I was wondering how to fix this, or if it was possible to add each iteration of a dynamic variable to a list?

Are you possibly reinitializing the list between iterations?