Close files after use

Replace the pattern:

  func(open(...))

by the pattern:

  with open(...) as f:
    func(f)

It ensures files are closed after use.

Change-Id: I7cdd08993ae4a094d101a1bf68ce700817e7fb92
Merge "Close files after use"