fix while-read bug