Ame sembra che la realloc debba essere scritta cosi'

if (!(word = (char *)realloc (word, sizeof(char) * (i+4))))

E la word1 e word2 non sembrano essere utilizzate ...