Check for errors: How to use ferror
#include <stdio.h> int main () { FILE *file; file = fopen("my.txt","r"); if (file==NULL) perror ("Error opening my.txt"); else { fputc ('e',file); if (ferror (file)) printf ("Error Writing to my.txt\n"); fclose (file); } return 0; }