added istream implementation