Debug This I: fgets() and fputs()

I ran in to an issue when working with fgets() and fputs(). Below code does not copy contents of 'Sample.txt' to file 'outFile.txt'. If anyone would like to identify the bug, feel free to leave a comment. Obvious cases are ruled out [file doesn't exist; there is nothing in input file; compilation errors; etc].
#include <stdio.h> 

#define MAXBUF 100 

int main() 
{
    char *in  = "Sample.txt"; 
    char *out = "outFile.txt"; 
    char buf[MAXBUF]; 

    FILE  *rfs,  *wfs; 

    rfs = fopen(in, "r"); 
    /* error checking required */

    wfs = fopen(out, "w");
    /* error checking required */

    while(fgets(buf, MAXBUF, rfs)) 
    {   
        fputs(buf, wfs);
    }   

    fclose(rfs); 
    fclose(wfs); 

    return 0;  
}

I found the solution on Stackoverflow. You can see the solution in this post.

Labels: , , ,