Just want to add on here that looping through a large number of records can hit database and API rate limits as well, and there can also be race condition issues. There's an example of how to add a delay to your loop block at the bottom of this post. That might resolve your issue and can also be good to try just to get additional context for debugging the issue. It may be worth exploring batching your data as well!