Stupid question: any reason to not have a 'if keys != ""'? This would avoid adding a useless newline. Probably not a big deal, though.