writing keys to the correct files now