added check & error print for keyfile.