Optimize "open" method with context manager

Use opening context manager to open a file.
Change-Id: Ice9be6350fd01cbf5eec686ac68d7fc8b5a4d5bd
6 files changed