also need to handle the Write() return < 0