EditorGUILayout.TextField changes back to first value I input [GIF of the problem inside]

When I input for example “aaa” in that text from the custom editor and then change it from another code. and then i click on the field again, my initial input “aaa” is set as the current value.

here is the full code:

public class TestingBug : EditorWindow {

string abc = "0";
int num = 0;

[MenuItem("aaa/bbb")] 
static void GettingWindow()
{
    GetWindow<TestingBug>();
}

private void OnGUI()
{
    abc = EditorGUILayout.TextField(abc, GUILayout.Width(200));

    num++;
    abc = num.ToString();

}

}

I don’t understand what the example is supposed to do, but the TextField displays the value of the variable abc. After you store the user’s input back in abc, you just end up overwriting it with the assignment abc = num.ToString (), and num is just incrementing every time OnGUI is called.