Botched refactor of writeKeyList.