title: Separate Text files from List into GUI Labels
body: <p>This code allows .txt files to be read and placed into a GUI Label and then displayed as on screen text. So far the txt files are placed into a List and then a <code>foreach</code> then assigns the variable. However, My problem is both text files are appearing together in each label rather than separately and I was wondering how would this be done?
  powersupply.txt is for the powersupply model and puzzles.txt is for the cdrw model. Any help is greatly appreciated.  </p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System.IO;
  // To use List
  using System.Collections.Generic;
  
  public class OnClick : MonoBehaviour
  {
      string cdrw = "CD-RW";
      string powerSupply = "Power Supply";
      public string txt;
      public static string completeText = "";
      public GameObject cdrwModel;
      public GameObject powerSupplyModel;
      public StreamReader reader = null;
      public FileInfo theSourceFile = null
      private static List&lt;string&gt; _allFiles = new List&lt;string&gt;();
  
      public void Start()
      {
          theSourceFile = new FileInfo(Application.dataPath + "/puzzles.txt");
          ProcessFile(theSourceFile);
          theSourceFile = new FileInfo(Application.dataPath + "/powersupply.txt");
          ProcessFile(theSourceFile);
      }
  
      private void ProcessFile(FileInfo file)
      {
          if (file != null &amp;&amp; file.Exists)
              reader = file.OpenText();
          if (reader == null)
          {
              Debug.Log("puzzles.txt not found or not readable");
          }
          else
          {
              while ((txt = reader.ReadLine()) != null)
              {
                  Debug.Log("--&gt;" + txt);
                  completeText += txt + "\n";
              }
              _allFiles.Add(completeText);     
          }
      }
  
      public void OnGUI()
      {
          if ((isClicked) &amp;&amp; (cdrwModel))
          {
              GUI.Label(new Rect(15, 35, 400, 400), "Press &lt;TAB&gt; for more information");
              if (Input.GetKey(KeyCode.Tab))
              {
                  foreach (var file in _allFiles)
                  {
                      GUI.contentColor = Color.red;
                      GUI.Label(new Rect(1000, 50, 400, 400), file);
                  }
              }
          }
          else if ((isClicked) &amp;&amp; (powerSupplyModel))
          {
              GUI.Label(new Rect(15, 35, 400, 400), "Press &lt;TAB&gt; for more information");
              if (Input.GetKey(KeyCode.Tab))
              {
                  foreach (var file in _allFiles)
                  {
                      GUI.contentColor = Color.red;
                      GUI.Label(new Rect(1000, 50, 400, 400), file);
                  }
              }
          }
      }
  }
  </code></pre>