diff --git a/src/main.c b/src/main.c
index 3376fa4..aba1c34 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1243,16 +1243,17 @@ grepfile (char const *file, struct stats *stats)
       return 1;
     }
 
-  if ((directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
-      || (devices == SKIP_DEVICES && (S_ISCHR (stats->stat.st_mode)
-                                      || S_ISBLK (stats->stat.st_mode)
-                                      || S_ISSOCK (stats->stat.st_mode)
-                                      || S_ISFIFO (stats->stat.st_mode))))
-    {
-      if (file)
-        close (desc);
-      return 1;
-    }
+  if (desc != STDIN_FILENO)
+    if ((directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
+        || (devices == SKIP_DEVICES && (S_ISCHR (stats->stat.st_mode)
+                                        || S_ISBLK (stats->stat.st_mode)
+                                        || S_ISSOCK (stats->stat.st_mode)
+                                        || S_ISFIFO (stats->stat.st_mode))))
+      {
+        if (file)
+          close (desc);
+        return 1;
+      }
