What gui would i need to make a chat log

Ok so im currently trying to use a gui.textarea and have it display a message that u type(which works only one time), but i run into a problem were when u enter a second message it loops the first message like crazy. Is there a different gui i should b using to make this more simplistic becasue i also want to be able to scroll through the log. This is going to be a MMO so we need chat functionailty soon since we are releasing alpha next week. If u would like to check my code here it is.

using UnityEngine; 
using System.Collections; 
using System.IO; 
using System.Text; 
[RequireComponent (typeof(GUITexture))]
public class ChatWindowPlacement : MonoBehaviour {
    public GUIStyle style;
    private GUITexture Image;
    private int Screen_width;
    private int Screen_height;
    public string stringToEdit = "";
    public TextMesh speechBubble;
	private ArrayList list;
	private string msglist = "";
    public bool chat = false;
	
    private string path = @"C:\Users\Fa7\Desktop\chatLog.txt";//change for server side
    bool userHasHitReturn = false;
    void Start () {
	   list = new ArrayList();
       Screen_width = Screen.width;
       Screen_height = Screen.height;
       Image = guiTexture;
       Image.pixelInset = new Rect (Screen_width / 100, Screen_height / 100, Image.pixelInset.width, Image.pixelInset.height);
       chatUpdate();
    }
 
    // Update is called once per frame
    void Update () {
 
 
    }
    void chatUpdate()
    {
 
 
    }
    void OnGUI() {
 
 	   GUIStyle boxStyle = "box";
       stringToEdit = GUI.TextField(new Rect(Screen.width /60f,Screen.height / 1.05f, 300,20),stringToEdit,25);
       Event e = Event.current;
       if(e.keyCode == KeyCode.Return)   
       {
       speechBubble.text = stringToEdit;
       chat = true;
 	   boxStyle.wordWrap = true;
 		 using (StreamReader sr = File.OpenText(path)) 
        {
            string s = "";
				Debug.Log(s);
				Debug.Log(list);
            while ((s = sr.ReadLine()) != null) 
            {
					
              list.Add(s);
            }
			
			foreach(string msg in list)
			{
				msglist += msg + "\n";
				
			}
			 
        }
       }
		
       else if(chat)
       {
         updater();
		
       }
		
      GUI.TextArea(new Rect(10,10,100,100),msglist,200);
       if(GUI.Button( new Rect(Image.pixelInset.x + Image.pixelInset.width / 1.1f, Screen_height - Image.pixelInset.y - Image.pixelInset.height + Image.pixelInset.height/ 20, Image.pixelInset.width / 15, Image.pixelInset.height / 10) , "", style) ){
         Debug.Log("Closing Chat");
         gameObject.SetActive(false);
 
       }
    }
 
    void updater()
    {
       if(chat)
       {
 
       if(File.Exists(path))
       {
 
 
         using (StreamWriter sw = File.AppendText(path))
         {
          sw.WriteLine(stringToEdit);
		  sw.Close();
          chat = false;
         }
       }
       }
    }
 
}

I think the issue is here:

foreach(string msg in list)

            {

                msglist += msg + "\n";

               

            }

instead of pulling the results from your array list, maybe trying to simply display the text on a new line as a new GUILabel ? Or appending the text to a predefined variable and placing the appended text on a new line. I’m not to sure, i am fairly new to Unity and C#, But i do have a great knowledge range of VB .Net. Just trying to give out some ideas. Hope it helps.

Poppabear

P.s.

You can still use your array list for its attended purpose (assuming i am correct on what the purpose is), and perform some simple cleanup method to clean up the text displayed on the GUI after so many lines.

Again, Hope this helps.