Here you go..
I used 2 textBoxes just replace it with richttextbox.text and your set tested and works

Code:
        private List<string> Chains = new List<string>();
        private List<List<string>> ContentChains = new List<List<string>>();
        private void button1_Click(object sender, EventArgs e)
        {
            
            string[] linesArray = textBox1.Text.Split('\n');
            int chainNr;
            foreach (string s in linesArray)
            {
                String[] array = s.Split(' ');
                if (!Chains.Contains(array[4]))
                {
                    Chains.Add(array[4]);
                    ContentChains.Add(new List<string>());
                }
                    chainNr = Chains.IndexOf(array[4]);

                    List<string> list = ContentChains.ElementAt(chainNr);
                    list.Add(array[3]);
            }

        }


        //Used to show values in another textbox
        private void button2_Click(object sender, EventArgs e)
        {
                int i = 0;
                foreach (String s in Chains)
                {

                    textBox2.Text += "Chain " + s + Environment.NewLine;
                    List<string> list = ContentChains.ElementAt(i);
                    int j=0;
                    foreach (String st in list)
                    {
                        
                        textBox2.Text += j + " " + st + Environment.NewLine;
                        j++;
                    }

                    i++;
                }
            

            
        }
Here is an preview of the output
Chain A
0 GLY
1 GLY
2 GLY
Chain B
0 GLY
1 GLY
2 GLY
3 GLY


greetz kristof