+ 1

Why is it necessary to close the file?

Any explanation?

13th Feb 2016, 3:50 PM
Nicolás Tomatis
4 Answers
+ 3
it's is not necessary if you use your file once, your program works fine if you do not close it. But if you use more than once its needed to close your file. Although its always good and safer close it after use it.
24th Feb 2016, 12:24 PM
Cawan Porto
Cawan Porto - avatar
+ 1
it saves the text file
25th Jun 2016, 1:51 PM
Oyuncu Doruk
Oyuncu Doruk - avatar
+ 1
I think there is one more advantage in using "with". Suppose you are working with a series of large files, where you are reading the content of each file to memory and do some computation. If you forget to close each file properly, you may quickly run out of memory or you may cause the OS to do unnecessary swaps, which affects the system performance.
4th Jul 2016, 10:52 PM
to free up memory used during file connection. just like when connect or disconnecting a rational db.
4th Apr 2016, 11:20 AM
Lloyd Mwaluku
Lloyd Mwaluku - avatar