call read method on stream conditionally