Why the count is written last
The count is only known when the work is done. Writing it last is the only honest position for it.
The test for a stream
Interrupt the stream in the middle. The test is the middle, and the middle is where the shape lives.