Nested loop fails to continue to the next Routine

OS : macOS Monterey 12.3.1
PsychoPy version : v2022.1.2
Standard Standalone? (y/n) : yes

What are you trying to achieve?:
I am trying to do a self-paced reading task with PsychoPy. I have 60 sentences in total, and each participant will be randomly assigned 10 sentences to read word by word using the Space key. For the 60 sentences, each sentence has two versions (e.g., version x and version y), and each participant also only see one of the versions, either x or y. The number of participants who see x and y need to be counterbalanced. At the same time, two attention checks will be implemented, one in between and one by the end.

What did you try to make it work?:
Because I am quite new to PsychoPy and Python, I find it difficult to achieve this two-level of randomization within PsychoPy. So I came up with a “stupid” idea, that I use Python to generate 800 condition files (I need 400 participants) in advance, and each file contains 5 sentences, and then I will assign different files to each participant to achieve this “fake” randomization. and Below is the flow of the experiment I have for now.

In both trial_A and trial_B, participants will read 5 sentences, after which they will answer a question for an attention check. To assign files to participants, I have two loops around each trial. The loop trial_a is in charge of the self-paced reading task, where words in sentences will be shown one by one, this is very standard.
The loop assign_A is in charge of assigning the files. The Conditions in this loop is an excel file with all the file names, below you can see an example.
截屏2022-04-28 21.01.04

I also set the loop properties as below, this will (hopefully) assign the participants with one random file name which will become the Conditions in the loop trial_a.

What specifically went wrong when you tried that?:
When I reach the end of the trial (i.e., all 5 sentences have been shown), the loop supposes to end and move to the first attention check, however, it is stuck at the last words of the sentences. It doesn’t move forward if I press Space, it also doesn’t automatically exit and report errors, all I can do is press ESC to exit the experiment. This only happens when I use two loops together, and if I delete either one of the loops, it can work perfectly.
Below is the message I get from the runner after exiting the experiment. I think there is something to do with the message
TSM AdjustCapsLockLEDForKeyTransitionHandling - _ISSetPhysicalKeyboardCapsLockLED Inhibit
I googled it, apparently, it is something about the CapLock for MacBooks, but I didn’t find a useful way to solve this problem.
Or, it could be something wrong that I didn’t notice when building the experiment with the Builder.

I also tried to change the setting of the allowed key ‘space’ from ‘constant’ to ‘set every repeat’ and the other way round, but it doesn’t seem to do anything.

Does someone know how I can solve this issue? Thank you very much!!

-----------ERROR MESSAGE--------------

Running: /Users/cqy/Desktop/Thick concept_SPR experiments/

6377.6245 INFO Loaded monitor calibration from [‘2022_03_15 16:00’]
1.3975 WARNING We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use [‘sounddevice’, ‘PTB’, ‘pyo’, ‘pygame’] (in that order).
8.2022 WARNING User requested fullscreen with size [1024 768], but screen is actually [1440, 900]. Using actual size
1.6213 WARNING Monitor specification not found. Creating a temporary one…
ioHub Server Process Completed With Code: 0
2022-04-28 20:29:08.429 python[44339:1432531] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/0z/wxpj73wn4hd5z925b2q_955c0000gn/T/org.opensciencetools.psychopy.savedState
2022-04-28 20:29:19.125 python[44339:1432531] TSM AdjustCapsLockLEDForKeyTransitionHandling - _ISSetPhysicalKeyboardCapsLockLED Inhibit
################ Experiment ended with exit code 0 [pid:44339] #################