fix stream reading by length