Fix input read bug