Question: I need recive multiple messages at client, but `ReadLineAsync()` only read first message.

```
    //Server Side
    StreamWriter StwWriter = new StreamWriter(client.GetStream())
    {
        AutoFlush = true
    };
    for (int i = 0; i < 10; i++)
    {
        StwWriter.WriteLine("test");
    }
    // Client Side
    public async void WaitMessages()
    {
        while (LoginChat.Client.Connected)
        {
            try
            {
                var reader = new StreamReader(LoginChat.Client.TcpClt.GetStream());
                var data = await reader.ReadLineAsync();
                MessageBox.Show(data);
            }
            catch (Exception ex)
            {
              MessageBox.Show(ex.ToString());  
            }
        }
    }
    WaitMessages();

```

The output only show the first message. What is wrong?

Answer: 
As i Provided in comment , you need to create steam outside while loop so code should be like this , it causing problem as you are creating stream every time in you code 

```
public async Task WaitMessages()
{
    var reader = new StreamReader(LoginChat.Client.TcpClt.GetStream());
    while (LoginChat.Client.Connected)
    {
        try
        {                
            var data = await reader.ReadLineAsync();
            MessageBox.Show(data);
        }
        catch (Exception ex)
        {
          MessageBox.Show(ex.ToString());  
        }
    }
}

```
The problem is reader.readlineasync(), would only get the first line from the text stream. To get the others, the file should be read continuously till the next line reads null. Check out this link to see how it's done <https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-read-a-text-file-one-line-at-a-time>