Hướng dẫn dùng line shuffler trong PHP

I am trying to read, shuffle, then display the contents of a text file. The text file contains a list of codes (each one on a new line - no commas etc).

1490
1491
1727
364
466
//...
783
784
786

My code:

$file = fopen("keywords.txt", "r");
shuffle($file);

while (!feof($file)) {
  echo "new featuredProduct('', ". "'". urlencode(trim(fgets($file))) ."')" . "," . "\n
"; } fclose($file);

The result I get is the following:

new featuredProduct('', '1490'), 
new featuredProduct('', '1491'), 
new featuredProduct('', '1727'), 
new featuredProduct('', '364'), 
new featuredProduct('', '466'), 
//... 
new featuredProduct('', '783'), 
new featuredProduct('', '784'), 
new featuredProduct('', '786'), 

I believed that I would have to shuffle the contents of the $file variable before looping through and displaying, and as you can see, the shuffle function is not working or I have not used it correctly?

I was expecting to see the list arranged a lot more randomly.