Mysterious line break in cout statement
<p>I wrote a small snippet to search for matched strings in an array, then output results for parallel arrays in a nicely formatted fashion. However, I must have some fundamental misunderstanding about how string outputs work, because for the life of me I cannot get this to output correctly, no matter where I put the tab, the newline, or whether I use an <code>endl</code> in my code.</p>

<p>Here is the relevant code below:</p>

<pre><code>for (int i = 0; i &lt; arrayCount; i++) {
    if (arrayCopy[i].find(localString) != string::npos) {
        cout &lt;&lt; "\n\t"
        &lt;&lt; array1[i] &lt;&lt; " {"
        &lt;&lt; subArray1[i] &lt;&lt; ", "
        &lt;&lt; subArray2[i] &lt;&lt; "}";
    }
}
</code></pre>

<p>I'm expecting results to have a tab at start of each line:</p>

<pre>
         MatchedString1 {Data, MoreData}
         MatchedString2 {Data, MoreData}
         MatchedString3 {Data, MoreData}
</pre>

<p>Instead I am getting results like below, where the tabs appear on blank lines (except for the first result):</p>

<pre>
         MatchedString1 {Data, MoreData}

MatchedString2 {Data, MoreData}

MatchedString3 {Data, MoreData}
</pre>

<p>What devilish quirk exists in c++ that is causing me so much pain?! </p>
