Check Return Values Bad Code: FILE* file = fopen("input.txt", "w"); fprintf(file, "hello world\n"); Good Code: FILE* file = fopen("input.txt", "w"); if (file) { fprintf(file, "hello world\n"); }