The main reason to close file after read and write operations, so the program does not slow down as Python makes sure that any unwritten or unsaved data is flushed off (written) to the file before it is closed. Hence, it is always advised to close the file once our work is done. Also, if the file object is re-assigned to some other file, the previous file is automatically closed.
If you keep a file open longer than it is like, you are wasting precious resources and potentially slowing down your system or making it run inefficiently.