Write a single message to file

def __to_file(self, message_no):
        """ Write a single message to file """
        filename = self.__create_file_name(message_no)
        try:
            with codecs.open(filename, mode='w',
                             encoding=self.messages[message_no].encoding)\
                    as file__:
                file__.write(self.messages[message_no].output)
        except IOError as excep:
            print 'Unable for open the file \'{0}\' for writing. The '\
                  'following exception was raised:'.format(filename)
            print excep
            print 'Exiting!'
            sys.exit(2)
        return filename