Correctly handle read() returning zero.