I saw many opinions on this. Some pythonist say that it might not close the file, some say it will close it automatically. I tested it with multiple python versions on multiple places and it always closed the file immediately when the file object refcount decreased to 0. This is why I joined the group of people who don't close the file if they use it in one line. (I still close it when I use it multiple times or in some function. But in this case I believe it's fine to just read it).