can i use open in map?

when i use with statement, the file will be closed automatically.

but can i use open in map function? will it be closed automatically?

Thanks!