def archiveYahooMessage(file, archiveFile, messageYear, format): try: f = open(archiveFile, 'a') f.write(loadYahooMessage(file, format)) f.close() print ('Yahoo Message: ' + file + ' archived to: archive-' + str(messageYear) + '.txt') except Exception as e: print ('Yahoo Message: ' + file + ' had an error:') print (e)