TOOLS-366: properly check for EOF