Writing key inputs to a file
<p>I'm compiling this code with GNU GCC Compiler in Code Blocks but for some reason the log file that it creates remains empty no matter what. Any ideas why this might be?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;

using namespace std;

int i;
string s;

int main()
{
    ofstream log;
    log.open("log.txt");
    while (!GetAsyncKeyState(VK_F8)) {
        for (i=65; i&lt;90; i++) {
            if (GetAsyncKeyState(i)) {
                s+=i;
            }
            Sleep(10);
        }

        if (GetAsyncKeyState(VK_SPACE)) {
            s+=" ";
        }
    }

    log &lt;&lt; s;
    log.close();
    cin.get();
}
</code></pre>
