Corrected getting encoding of stream.