How can I make a int instantly wright to an already existing txt file?

To read I have this code

public static int LevelOn = 1;//highest level unlocked
    	public TextAsset textFile;
    
    
        void Update()
        {
            string text = textFile.text;  //this is the content as string
            byte[] byteText = textFile.bytes;  //this is the content as byte array
            LevelSelect.LevelOn = int.Parse(text);
        }

And to Write have this code

File.WriteAllText (Application.dataPath + "\\Resources\\currentLevel.txt", LevelSelect.LevelOn.ToString ());

But it takes a few minutes to actually load to the txt file. but if I stop running unity and open the txt it wrights to it.

How can I make it instantly wright to the txt file?

After you write to the file run this:

AssetDatabase.Refresh();

This will make sure Unity isn’t using a cached version of the file.

Documentation: Unity - Scripting API: AssetDatabase.Refresh

And more on it at the bottom of this page: Unity - Manual: The Asset Database