fix: handle EOF correctly

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>