diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 230d476eb09467d7aa9347dac04e9264437c2b44..1bd00adeb899f4b85c08ddbe69020c74bb2141c9 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -587,8 +587,6 @@ function system_file_download($uri): Response {
         if (array_intersect($parts, ['.', '..'])) {
           return -1;
         }
-        // Default response when the file is not found.
-        return new Response('File not found', 404);
       }
     }
   }
@@ -605,6 +603,9 @@ function system_file_download($uri): Response {
       ];
     }
   }
+
+  // Default response when the file is not found.
+  return new Response('File not found', 404);
 }
 
 /**