Replaced catch() with check for unknown stream length