Ugh even I get confused by streams, there are no infinite loops.

Yeah overwriting pipe and setting a flag would work.