[common] use with statement to open files

4 jobs for issue-73-cannot-push-a-cxx-algorithm in 4 minutes and 40 seconds (queued for 5 seconds)