terminate on reading 0 bytes