Read an open .txt file online by C#

I have a text file contained of values separated with coma. I read it by C# with TextAsset and parsing the values by split. My program is working when I have a produced saved text file. This file is produced with a device and the problem is that I want to read it when it being written simultaneously. But unity will crash when I try to run the device and unity at the same time. I tried to make a delay between writing and reading by WaitForSeconds or Thread.Sleep but none of them worked :frowning: would you please help me how can I read an open text file when the file is during being written.
the data are like:
and my C# code is:
public float t = 0f;
public float X = 0f;
public float Y = 0f;
public float Z = 0f;

	public TextAsset data;

	void Update ()
		string[] dataLines = data.text.Split('

string dataPairs = new string[dataLines.Length];
int lineNum = 0;
foreach (string line in dataLines)
dataPairs[lineNum++] = line.Split(’,');
for (int i = 0;i<=lineNum;i++)
t = float.Parse (dataPairs*[0]);*

_ X = float.Parse (dataPairs*[1]);_
_ Z = float.Parse (dataPairs[2]);
Y = float.Parse(dataPairs[3]);
transform.position = new Vector3(X,Z,Y);

* }*

Check the file functions at MSDN to see if there is something about locking or whatnot, and check for locked file before trying to open it, or use a try/catch around opening it. You can also use Sockets for transferring data if your data source supports that.