switched to using 'with' for key file loading