def METHOD_NAME(self, properties):
    try:
        # Get node
        node = slicer.mrmlScene.GetNodeByID(properties["nodeID"])
        # Write node content to file
        filePath = properties['fileName']
        with open(filePath, 'w') as myfile:
            myfile.METHOD_NAME("magic\n")
            myfile.METHOD_NAME(node.GetText())
    except Exception as e:
        import traceback
        traceback.print_exc()
        errorMessage = f"Failed to write file: {str(e)}"
        self.parent.userMessages().AddMessage(vtk.vtkCommand.ErrorEvent, errorMessage)
        return False
    self.parent.writtenNodes = [node.GetID()]
    return True