making read() loop work for multiple read