Program to write and read data from a file

Program:

#include<stdio.h>
#include<conio.h>
void main()
{
    char c;
    FILE *fptr1;
    clrscr();
    printf("Enter the text to be stored in the file.\n");
    printf("Use ^Z or F6 at the end of the text and press ENTER: \n\n");
    fptr1 = fopen("COURSES.DAT","w");
    while((c = getc(stdin)) != EOF){
        fputc(c, fptr1);
    }
    fclose(fptr1);
    printf("\nThe content of the file is : \n\n");
    fptr1 = fopen("COURSES.DAT", "r");
    do
    {
        c = fgetc(fptr1);
        putchar(c);
    } while(c != EOF);
    fclose(fptr1);
    getch();
}

Output:

Enter the text to be stored in the file.
Use ^Z or F6 at the end of the text and press ENTER:
Computer Science & Engineering
Information Technology
Electronics & Communication Engineering
^Z
The content of the file is :
Computer Science & Engineering
Information Technology
Electronics & Communication Engineering