Soft 404
.
I should have done a quick search first. This page
https://www.tutorialspoint.com/python/file_close.htm#:~:text=Python%20file%20method%20close%20%28%29%20closes%20the%20opened,Calling%20close%20%28%29%20more%20than%20once%20is%20allowed.
says
Python automatically closes a file when the reference object of a file is reassigned to another file.
so it looks like you're fairly safe in what you're doing.