def saveAsciiFile(self, filename, encoding = "default"):
        """ Saves to ascii file, strips trailing blank lines """
        try:
            if encoding == "default":
                f = open(filename, 'w')
            elif encoding == "cp437":
                f = open(filename, 'w', encoding="cp437")
            elif encoding == "utf-8":
                f = open(filename, 'w', encoding="utf-8")
        except:
            self.notify("Could not open file for writing. (Press any key to continue)", pause=True)
            return False
        # rewrite this. rstrip(' ') looks cool, though.
        outBuffer = '\n'.join(''.join(line).rstrip(' ') for line in self.mov.currentFrame.content).rstrip('\n')
        try:
            f.write(outBuffer + '\n\n')
        except UnicodeEncodeError:
            self.notify(f"Error - some characters cannot be saved using encoding {encoding}. (Press any key to continue)", pause=True)
            f.close()
            return False
        f.close()
        return True
 Saves to ascii file, strips trailing blank lines 
durdraw/durdraw_ui_curses.py