#include <stdio.h>

#define MAX_WORD_SIZE 100

int read_word(FILE *f, char *s)
{
    int c, d, i = 0, status = 0;
    while (1) {
	c = fgetc(f);
	if (c == EOF) { 
	    s[i] = '\0';
	    return 0;
	}
	if (c >= 'A' && c <= 'Z') d = c - 'A';
	else if (c >= 'a' && c <= 'z') d = c - 'a';
	else d = -1;
	if (d == -1) {
	    if (status == 1) {
		s[i] = '\0';
		return 1;
	    }
	}
	else {
	    s[i] = d + 'a';
	    i++;
	    if (status == 0) status = 1;
	}
    }
}


int main(int argc, char **argv)
{
    FILE *f;
    char *infile = argv[1];
    int c, d;
    char buf[MAX_WORD_SIZE];

    f = fopen(infile, "r");
    if (f == NULL) {
	printf("File %s could not be opened. Exiting.\n", infile);
	return 1;
    }
    /* while ((c = fgetc(f)) != EOF) { */
    /* 	if (c >= 'A' && c <= 'Z') d = c - 'A'; */
    /* 	else if (c >= 'a' && c <= 'z') d = c - 'a'; */
    /* 	else d = -1; */
    /* 	if (d == -1) printf(" "); */
    /* 	else { */
    /* 	    d = (d + 13) % 26; */
    /* 	    printf("%c", d+'a'); */
    /* 	} */
    /* } */

    while (read_word(f, buf)) {
	printf("%s\n", buf);
    }
    return 0;
}

