When you create a file object, a file
object is created in RAM, and it's going
to remain there until the execution of
your program ends. Therefore, it might
be a good idea to actually close the
file, and so that the file is deleted
from the memory, once you are done
processing that file. For example, in
this script, you are creating the file
object, and here you are reading the
content of that file object and storing
it as a string. So myfile.read
output a string, which represents the
text of the file, that stream will be
stored in this content variable. So here
I'm done with processing the file, then
I can, after that, I'm just processing
the stream that I saved in this
variable. Therefore, it makes sense to
apply myfile.close, even
though this is not strictly mandatory,
but it's a good idea to use it. So if
you do that, you'll still get the
correct output. Something, you should
know now is that if you apply myfile.read
again, after you have
closed the file, you're going to get an
error. It says that this operation is
being performed on a closed file, so you
cannot do that. So this is how to create
a file and close it. But there is a better
way to do all that. I'll show you that
in the next video.
[No audio]