<?php $fh = fopen('novel.txt','r') or die($php_errormsg); while (! feof($fh)) { if ($s = fgets($fh)) { $words = preg_split('/\s+/',$s,-1,PREG_SPLIT_NO_EMPTY); } } fclose($fh) or die($php_errormsg); ?>