#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
    FILE *fp;
    char ch;
    
    fp = fopen("words.txt", "w");
    printf("Enter data and type Ctrl-Z (windows) or Ctrl-D (Linux) to close file.\n");
    
    while( (ch = getchar()) != EOF) {
        putc(ch, fp);
    }
    fclose(fp);
    
    printf("\n\nFile contents\n\n");
    
    fp = fopen("words.txt", "r");
 
    while((ch = getc(fp)) != EOF)
       printf("%c",ch);
    
    fclose(fp);
    return 0;
}


