Looping on read() with a return of 0