I know this is an older post, but we were experiencing a similar issue in version 11.2.2 and I thought I'd post what we found so that it might help others with the same issue. This seems like a bug to me, but maybe there is some explanation as to why it works this way.
When initializing a loop, we were using the "PrevTask" variable to reference the Task that was retrieving the list of values to loop over. This worked in earlier versions before we upgraded and this method was preferred because we often clone jobs, so the fewer explicit Variable Id's we need to update when doing so the better.
PROBLEM:
For Each Row X in: {TASK(PrevTask|StdOut)}
While this worked in most instances, we experienced issues anytime a Task within the loop had a Condition tied to it that was not met. At this point, the Action "On Match None > Next" would get triggered and the variable that was initialized for the For..Each loop would get completely wiped out. This meant that once the loop completed, it would no longer contain the values needed for its next iteration over the value list that was originally set because it no longer existed.
The fix was to completely avoid using the "PrevTask" variable in the For..Each loop initialization, and instead, explicitly reference the Task Id for the Task responsible for retrieving the list of items to loop over (Ex. List Files In Directory).
FIX:
For Each Row X in: {TASK(faa28d28-9902-4e66-afc2-8deee479e471|StdOut)}
Hope this helps someone else in need of an answer.