optimized used RAM by not reading the whole key file