GetAsyncKeyState and ofstream
<p>Hi i am new to C++ and i were looking for function GetAsyncKeyState and i did a small app to get "A" and "B" Keys if pressed in a file named log.txt and it works fine but i have a Question:</p>

<p>i added  endl; in each if statement so it is end the line and go to the second line and add the next letter, but when i remove the endl; it didn't put any letters >> ( i removed the endl; as i want all letters to be in the same line )</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;fstream&gt;
using namespace std;
int main ()
{
    ofstream logfile("log.txt", ios::out | ios::ate | ios::app);

    while (true)
    {
        Sleep (100);
        if (GetAsyncKeyState(0x41))
            logfile &lt;&lt; "a" &lt;&lt; endl;
        if (GetAsyncKeyState(0x42))
            logfile &lt;&lt; "b" &lt;&lt; endl;
    }
}
</code></pre>
