weird symbol getting appended at the end
<p>I am trying to read characters from a file and writing them to another. The problem is, though everything is being written, a weird symbol is getting appended in the next line of write file. My code is:</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;stdlib.h&gt;
#include&lt;string.h&gt;
#include&lt;stdio.h&gt;

using namespace std;

int main(){

    FILE *f, *g;
    int ch;
    f = fopen("readfile", "r");
    g = fopen("writefile", "w");
    while(ch != EOF){
            ch = getc(f);
            putc(ch, g);
    }
    fclose(f);
    fclose(g);
return 0;
}
</code></pre>

<p>What may be the reason for that? </p>
