first you need to store the words in a serialised formant so that means
$file_location = "/foo/bar/words.txt";
$words = array("game", "cool", "why");
$words = serilize($words);
write_words_file($words, $filelocation); //Create the function so it can write to a file
then you will need to edit your init_words
function init_words($file)
{
global $words;
$data = file_get_contents($file);
$words = unserialize($data);
$count = count($words);
echo "$count words
\n"; // "3 words"
}
init_words("/foo/bar/words.txt");
$count = count($words);
echo "$count words
\n"; // "0 words"