diff --git a/src/scripts/pycompare.py b/src/scripts/pycompare.py
index 03cc1ac2dadae80709e79460bd6fcc437f1419b9..252000b327d5a7a9100a26979c428bff3265be49 100755
--- a/src/scripts/pycompare.py
+++ b/src/scripts/pycompare.py
@@ -180,7 +180,8 @@ def compare_files(config):
                 mismatch_count['warnings'] += line_result[1]
                 mismatch_count['noisy'] += line_result[2]
                 if (mismatch_count['errors'] > 0 and not config['check_all']):
-                    print("INFO: mismatch found at line %d"%(li + 1))
+                    print("INFO: mismatch found at line %d"%(num_read_lines))
+                    line_loop = False
                     break
         else:
             mismatch_count['errors'] = len(c_lines)