Guard open calls with with statements when possible