Trouble retriving Value from dictionary C# : I've seen a few similar questions but I've been unable to find a suitable answer so far. I'm coding a client and a server for a project, where the client will submit a user and their location to the server. The server will then store this information in a dictionary. 

Here is the client code:    

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Net;
    using System.Net.Sockets;
    using System.IO;
    
    
    public class Whois
    {
        static void Main(string[] args)
        {
            TcpClient client = new TcpClient();
            try
            {
                client.Connect("localhost", 43);
                StreamWriter sw = new StreamWriter(client.GetStream());
                StreamReader sr = new StreamReader(client.GetStream());
                if (args.Length == 2) 
                {
                    sw.WriteLine(args[0] + " " + args[1]);
                    sw.Flush();
                    sw.Close();
                    sr.Close();
                    Console.Read();
                }
                else
                {
                    sw.WriteLine(args[0]);
                    sw.Flush();
                    sw.Close();
                    sr.Close();
                    //Console.WriteLine(args[0] + " is " + sr.ReadToEnd());
                    Console.Read();
                }
            }
            catch
            {
                Console.WriteLine("Something went wrong there, surprisingly.");
            }
            
        }
    }

And here is the server:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Net;
    using System.Net.Sockets;
    using System.IO;
    
    namespace locationserver
    {
        class Program
        {
            static void Main(string[] args)
            {
                Dictionary<string, string> dictionary = new Dictionary<string, string>();
                RunServer(dictionary);
                
            }
    
    
            static void RunServer(Dictionary<string, string> dictionary)
            {
                Console.Clear();
                TcpListener listener;
                Socket connection;
                NetworkStream socketStream;
            
                Console.WriteLine("Dictionary list -----------------");
                List<string> list = new List<string>(dictionary.Keys);
                foreach (string k in list)
                {
                    Console.WriteLine("{0}, {1}", k, dictionary[k]);
                }
                Console.WriteLine("---------------------------------");
    
                try
                {
                    listener = new TcpListener(IPAddress.Any, 43);
                    listener.Start();
                    Console.WriteLine("Server started listening...");
                    while (true)
                    {
                        connection = listener.AcceptSocket();
                        socketStream = new NetworkStream(connection);
                        
                        DoRequest(socketStream, dictionary, listener);
                        //socketStream.Close();
                        //connection.Close();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Console.ReadLine();
                    RunServer(dictionary);
                }
            }
    
    
            static void DoRequest(NetworkStream inputStream, Dictionary<string, string> dictionary, TcpListener listener)
            {
    
                string[] temp;
                string streamInput;
                
                StreamWriter sw = new StreamWriter(inputStream);
                StreamReader sr = new StreamReader(inputStream);
    
                streamInput = sr.ReadToEnd();
                if (streamInput.Contains(" "))
                {
                    temp = streamInput.Split(' ');
                    dictionary.Add(temp[0], temp[1]);
                    listener.Stop();
                    RunServer(dictionary);
                }
                else
                {
                    try
                    {
                        Console.WriteLine(streamInput);
                        Console.WriteLine(dictionary[streamInput]);
                        Console.ReadLine();
                        listener.Stop();
                        RunServer(dictionary);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        Console.ReadLine();
                        listener.Stop();
                        RunServer(dictionary);
                    }
                }
    
                    
            }
    
        }
    }

The client is succesfully transmitting the data to the server, and the server prints out the dictionary at once the data has been recieved for the purpose of error checking, yet when I try to access the key's corresponding value in the dictionary, it isn't there. Any help would be great. 


    