with

with 文を使うと終了処理が必ず実行される。
with open( "test.txt" ) as f: for s in f: print s;