Add function to write keys to file.