Scheduled task sending email non stop

Hi all,
Need help to figure out the root cause to ensure the same error won't happen again.
I have a scheduled task running every month.
This is the second time the scheduled task went wrong and sent thousands of emails..

I have 6 identical query iterators and the actions follow it( my variable setting is not working in this case)
Screenshot 2024-05-27 101256
The one went wrong is the query iterator2.
(The iterator1 set up should be the same as iterator2, but I noticed the export dataset1 became the last step).
Is it the reason causing the error?
Also from the history, I can see the task ran for around 3 hours.


Does this happen before?
Please let me know if you need more information.
Thanks

Irene

It's hard to say what happened here, but how about changing that while file exists do email and delete file to if file exists then email and delete file.

Thank you John, I will change the action. Will test again and hopefully the error won't happen again.