Please fix the condition in the IF.
Update the condition to below in IF condition. Because you are starting transaction number from zero, in the condition you do not need to keep less than or equal to.
in_TransactionNumber < dtWoItem.Count
Regards,
Karthik Byggari