Writing keys in file