Change open(file) to with block

Currently script which loads metadata definitions to database
uses open(file) to stream files. This isn't the best practice
because in case of any errors this code may not be safe.
To solve this problem this patch changes open(file) to
'with open(file) as...:' block. It allows us to ensure that every
resource is cleaned up when the code finishes running.

Change-Id: I4a85700061ed5050f4356f1b39ea128931626c83
Closes-Bug: #1367172
Merge "Change open(file) to with block"