I know that some time has passed since this issue was active, but here is a different solution in any case, if someone is interested.
Your path seems fine, but here is a similar strategy using the list.index() method:
starts = [lines.index(l) for l in lines if l.startswith('sub')]
Over time, the two functions work the same way (on average 1.7145156860351563e-06 seconds for your enumerate solution and 1.7133951187133788e-06 seconds for my .index() solution)
sacul source share