what if an exception occurs while processing your file? Then my_file.close() is never executed. You can handle this with exception-handling syntax or with context managers
**`with a`` block to handle exceptions:
>>> with open('filename.csv', 'w') as my_file:
... # do something with `my_file`
Using the with block means that the special methods .enter() and .exit() are called, even in the cases of exceptions