fixed keyvaluepairs in writing files

ValueError: too many values to unpack
was thrown before, because for loop over dictionary only returns key as loop variable. Values would have to be extracted manually from dictionary using get().

Use of .items() allows iteration over keys and values