StartDThis is part of the main stream,StartAbut this is part of the A stream.EndAwhile this
is again part of the main stream.

Of course it could be more difficult:

SStStaStarStartStartBis where stream B starts
and this can be several lines long
and ends when we see EndB

and...

StartC
Lets see if this ends up again in the main stream
EndCStartE, because it should not...
EndE

and the next one should be

SClosed
closed early
EClosed

and this is the end.
EndD