fixed matching 'endstream' in stream reading