in reply to Split files based on regexp
If it is a big file, read it one line at a time instead of slurping into an array.
Look up Finite-State Machine (FSM) on Google. Your app toggles between SEARCHING_FOR_ENTERCOMBAT and FIND_THE_BOSS states.