Fix input stream bug