but why write sentinel text to the stream? You'll be able to tell already if nothing happened because the stream will be empty.

Writing sentinel text is fragile, because if your 'test input' is shorter than the sentinel then it won't come out right. Seems to add complication without adding value unless I'm missing something