EditorGUILayout textfield return value problem

Hi, How can I make the EditorGUILayout textfield to return the correct string value?

string levelPath = "C:\\Levels\\LevelTest.txt";
levelPath = EditorGUILayout.TextField(levelPath);
print(levelPath);

for the above code, Whatever I type in my textfield, levelPath just return "C:\Levels\LevelTest.txt"... Any idea to fix this?

// outside the function
string levelPath = "C:\\Levels\\LevelText.txt";

void OnGUI()
{
    levelPath = EditorGUILayout.TextField(levelPath);
    print(levelPath);
}

The problem is you're re-initializing the variable every time. You need to make it a member variable and not continuously re-assign it.