[FIX] chunk length to be a constant
[FIX] main stream loop so that there is only one ouputStream connection