path = "C:\Users"
for file_item in os.listdirs(path):
file_item_full = path + "https://stackoverflow.com/" + file_item
#check if the file_item_full name exists in the index file
i would do it like this, you can first read the file and add all lines in a list so you are not reading all the times the index file.
solved How can I check if a file exist in a index file?