tools: handle end of file errors