replace all the occurrences of previous string in msgs for an empty string, substitute the result for msgs. call the function io.open with 3 arguments: pofile, string 'w' and encoding set to string 'utf-8' as arguments,
with io . open ( pofile , 'w' , encoding = 'utf-8' ) as fp :