Read input stream logic is corrected (#14533).

Change-Id: I1a8a895d631889e04f7acbde29306e86da344a23