while(read == 0) should be enough.