Process cycles through a task list, on the second task the process fails on a terminal session activity

Hello! I have searched for a similar problem and I cannot find one. I built a process that cycles through a list of tasks. This process gathers information from an AS400 session, enters information into a Word document template, and prints the template. It then picks up the next task. The process works as expected through the first task. About halfway through the process of the second loop (second task), the process fails at the same spot.

The AS400 I’m working in has a processing “side” and an inquiry “side.” I use Send Key Attention to flip between the two because I need information from both. When the process flips to the Inquiry side during the second loop, enters the correct option in the correct position, and transmits, the session gives this error: “The option you selected is not valid.” This is the second time through the process, so it works in the first loop.

I’ve tried capturing the error message with a Get Text at Position activity, using an if activity to see if it exists, then use the Send Key Reset, then put in the selection a second time, and I still get the error.

I’ve also put the entire terminal sequence together, so that the process opens and closes the AS400 for each task. The process will loop through all tasks this way. But I was hoping to find a way to make it work where the terminal session signs on once & loops through all tasks before closing.

Any tips would be greatly appreciated!