One thing I saw, is, that very often the path is created simple by adding strings
so instead of filename = dir + "/file" it should used filename = os.path.join(dir, "file")
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One thing I saw, is, that very often the path is created simple by adding strings
so instead of filename = dir + "/file" it should used filename = os.path.join(dir, "file")
should be fixed now (at least in most cases)