diff --git a/core/base/src/TApplication.cxx b/core/base/src/TApplication.cxx
index e65fb01708c0b996d53eece70b8fc271aebf8df6..c485b5ebe21e7b1b97fdae83ee7ae5b9faf653db 100644
--- a/core/base/src/TApplication.cxx
+++ b/core/base/src/TApplication.cxx
@@ -929,7 +929,7 @@ Long_t TApplication::ExecuteFile(const char *file, Int_t *error, Bool_t keep)
       }
       if (!*s || *s == '#' || ifndefc || !strncmp(s, "//", 2)) continue;
 
-      if (!strncmp(s, ".X", 2) || !strncmp(s, ".x", 2)) {
+      if (!comment && (!strncmp(s, ".X", 2) || !strncmp(s, ".x", 2))) {
          retval = ExecuteFile(s+3);
          execute = kTRUE;
          continue;