Use set() to get only unique elements of a list.
Use `or` in assignments to deal with empty values as in `x = s or "<no text!>"`
Use `with open() as` syntax to get close() to happen automatically.
Python had a built-in object called file so avoid using that as a variable name.
Avoid naked exceptions. See https://realpython.com/blog/python/the-most-diabolical-python-antipattern/