title: Loop through the files in a directory/folder, filter them and then read information from them line by line
body: <p>I want to cycle over files in a folder, and read some data from them:</p>
  
  <pre><code>directory = os.fsencode(directory)
      for file in os.listdir(directory):
          file = os.fsdecode(file)
          if file.endswith(".log"):
              with open(file) as f:
                  for line in f:
                     extract(line=line))
  </code></pre>
  
  <blockquote>
    <p>with open(file) as f: FileNotFoundError: [Errno 2] No such file or
    directory: b'access.log'</p>
  </blockquote>
  
  <p>This is 'strange' because the file exists.</p>