Keep DuplexStream outside of anonymous closure