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: 
`StreamReader` has internal buffer, so when you do this:

```
var reader = new StreamReader(LoginChat.Client.TcpClt.GetStream());
var data = await reader.ReadLineAsync();

```

It might have read much more than one line. It's not a problem if you then continue using the same `StreamReader` instance to fetch next lines, but you just read one line then discard `StreamReader`. That means everything that was in its buffer is lost.

To fix - don't create new `StreamReader` in every loop iteration, but use one instance:

```
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>