title: WPF RichTextBox First Line \n is not Printed
body: <p>I have a very simple WPF application which only have a RichTextBox and a button declared like this:</p>
  
  <pre><code>&lt;Window x:Class="TestApp.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:local="clr-namespace:SimpleChessWPF"
          mc:Ignorable="d"
          Title="MainWindow" Height="670.8" Width="741.8"&gt;
    &lt;Grid&gt;
      &lt;RichTextBox HorizontalAlignment="Left" Height="534" Margin="10,97,0,0" VerticalAlignment="Top" Width="715" Name="TestRtb"&gt;
        &lt;RichTextBox.Resources&gt;
          &lt;Style TargetType="{x:Type Paragraph}"&gt;
            &lt;Setter Property="Margin" Value="0"/&gt;
          &lt;/Style&gt;
        &lt;/RichTextBox.Resources&gt;
      &lt;/RichTextBox&gt;
      &lt;Button Content="Button" HorizontalAlignment="Left" Margin="105,31,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/&gt;
    &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>And then I tried to make an event to print out some test texts when the button is pressed like this:</p>
  
  <pre><code>  public partial class MainWindow : Window {
      public MainWindow() {
        InitializeComponent();
      }
  
      private void Button_Click(object sender, RoutedEventArgs e) {
        TestRtb.Document.Blocks.Clear();
        for(int i = 0; i &lt; 64; ++i) {
          TestRtb.AppendText("i: " + i.ToString() + "\n");
          printBits(i);
          printBits(toBitSquare(i));
          TestRtb.AppendText("\n");
        }
      }
  
      private void printBits(int i) {
        string text = i.ToBitArrayString();
        TestRtb.AppendText(text + "\n");
      }
  
      public static int toBitSquare(int square) {
        return ((square &amp; ~7) &gt;&gt; 1) | (square &amp; 7);
      }
    }
  </code></pre>
  
  <p>'ToBitArrayString()' is my own <code>int</code> extension. It is basically used to print its bit array representation. And this is what happen when I run my program and press the button:</p>
  
  <p><a href="https://i.stack.imgur.com/TiFbZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TiFbZ.png" alt="enter image description here"></a></p>
  
  <p>Everything works as expected, except the first line "\n" is not printed. What happened?</p>
  
  <p>Just in case you want to replicate, my extension functions are as follow:</p>
  
  <pre><code>private static string toBitArrayString(BitArray b, int spacePerByte = 1, int spacePerNibble = 0) {
    StringBuilder sb = new StringBuilder();
    for (int j = b.Length - 1; j &gt;= 0; --j) {
      int i = b.Length - 1 - j;
      if (i % 4 == 0 &amp;&amp; i &gt; 0 &amp;&amp; spacePerNibble &gt; 0)
        sb.Append(string.Concat(Enumerable.Repeat(" ", spacePerNibble)));
      if (i % 8 == 0 &amp;&amp; i &gt; 0 &amp;&amp; spacePerByte &gt; 0)
        sb.Append(string.Concat(Enumerable.Repeat(" ", spacePerByte)));
      sb.Append(b[j] ? 1 : 0);
    }
    return sb.ToString();
  }
  
  public static string ToBitArrayString(this int input, int spacePerByte = 1, int spacePerNibble = 0) {
    BitArray b = new BitArray(new int[] { input });
    return toBitArrayString(b, spacePerByte, spacePerNibble);
  }
  </code></pre>