There is an easy way to read 'words' from a textfile, if 'word' is defined as splitted by all whitespaces.
You dont need to read all lines in your allocated line-array, your readfile function should...