#include <stdlib.h>
#include <stdio.h>
FILE *arqtxt;

main ( )
{
     char palavra[256];

     arqtxt = fopen ( "grava.txt", "wt" );      
     if (arqtxt == NULL)
     {   
          printf ("ERRO!\n");
          exit(1);
     }

     for ( ; ; )
     {
         scanf  ("%s",palavra);		     
    	 fprintf(arqtxt, "%s ", palavra);
	 if (strcmp(palavra,"FIM") == 0)
	    break;
     }	
			         
     fclose (arqtxt);
}
