with keyword triggers a context manager. Context managers automatically set up and take down data connections, or any other kind of object that implements the magic methods
The above code automatically closes
with open("test.txt", "r") as file: do_things(file)
withblock exits, so you never have to manually do a
file.close(). Most connection types, including file readers and database connections, support this.