Use safe way through "with" statement to work with files
Use safe way through "with" statement to work with files

It's unsafe to just open and write to file. Cause if something went wrong
during writing to file we won't close fd.

Change-Id: I924b8962b3e0c936f3a20260844178783feaf544

vuntz/glance,scripnichenko/glance,wkoathp/glance,jumpstarter-io/glance,darren-wang/gl,paramite/glance,stevelle/glance,tanglei528/glance,rajalokan/glance,akash1808/glance,vuntz/glance,scripnichenko/glance,kfwang/Glance-OVA-OVF,JioCloud/glance,redhat-openstack/glance,saeki-masaki/glance,rajalokan/glance,takeshineshiro/glance,openstack/glance,ozamiatin/glance,akash1808/glance,sigmavirus24/glance,dims/glance,saeki-masaki/glance,klmitch/glance,paramite/glance,kfwang/Glance-OVA-OVF,stevelle/glance,redhat-openstack/glance,sigmavirus24/glance,dims/glance,openstack/glance,jumpstarter-io/glance,tanglei528/glance,klmitch/glance,wkoathp/glance,openstack/glance,takeshineshiro/glance,ozamiatin/glance,JioCloud/glance,darren-wang/gl