Fix reading document from stream