diff --git a/contracts/management/commands/import_old_contracts.py b/contracts/management/commands/import_old_contracts.py
index d25d519f38c83a4b4dbe7058055500ea65a98d0c..73ecca61907ce56639e4d29dea73774c4afca09c 100644
--- a/contracts/management/commands/import_old_contracts.py
+++ b/contracts/management/commands/import_old_contracts.py
@@ -1062,6 +1062,8 @@ class Command(BaseCommand):
 
                         continue
 
+                    at_least_one_incorrect_filename = False
+
                     for file_data in value:
                         if not isinstance(file_data, dict):
                             observed_issues_count += 1
@@ -1081,8 +1083,6 @@ class Command(BaseCommand):
 
                             continue
 
-                        at_least_one_incorrect_filename = False
-
                         for file_key, file_value in file_data.items():
                             file_key = file_key.strip()