diff --git a/src/crlcache.c b/src/crlcache.c
index 88c48c3..59a3a06 100644
--- a/src/crlcache.c
+++ b/src/crlcache.c
@@ -460,12 +460,14 @@ check_dir_version (FILE **fpadr, const char *fname,
 {
   char *line;
   gpg_error_t lineerr = 0;
+  int gotline = 0;
   FILE *fp = *fpadr;
   int created = 0;
 
  retry:
   while ((line = next_line_from_file (fp, &lineerr)))
     {
+      gotline = 1;
       ++*lineno;
       if (*line == 'v' && line[1] == ':')
         break;
@@ -477,6 +479,11 @@ check_dir_version (FILE **fpadr, const char *fname,
         }
       xfree (line);
     }
+  if (!gotline)
+    {
+      log_error (_("no lines in `%s'\n"), fname);
+      return gpg_error (GPG_ERR_CONFIGURATION);
+    }
   if (lineerr)
     return lineerr;
 
