Added .encode('utf-8') during file write