Accessing folder through os.scandir() after changes made to folder
I am trying to iterate through a folder with html files to filter them according to whether they contain a keyword or not in their string form. I download them to a folder through wget and BeautifulSoup and iterate through it after downloading with os.scandir() and copy the passing files to a different folder. However, first time I run the script, I can only download them, and no file will be copied to the destination directory. When I run it a second time, it does filter properly.