title: How to iterate over the loop
body: <p>I have written this code to iterate through the files 0-100. The problem is when log file 0 is not found it is not going to next file. </p>
  
  <p>I tried to use <code>return i +1</code> which did not work as i am new to coding I don't know how to proceed. how to ignore the empty files and proceed to next. Should i keep a counter?</p>
  
  <pre><code>import os
  
  path = "C:\\Users\\Bindu\\Documents\\Thesis\\lfiles\\"
  
  list = os.listdir(path)  # dir is your directory path
  number_files = len(list)
  print(number_files)
  try:
        for i in range(0, 100):
          path2 = "data." + str(i) + "\\Log." + str(i)
          file = path + path2
  
          f = open(file)
          if not os.path.exists(path2):
              with open(path2) as fi:
                  if not fi.read(3):  # avoid reading entire file.
                      print("File is empty")
  
  except Exception as e:
       raise SystemExit("File empty")
  </code></pre>