ע"י פונקצית fgets אנו קוראים שורות מתוך הקובץ שימו לב:
<?php
// open the param.txt file read only
$file = fopen("students.txt", "r");
//Print all the lines from the file until end of file
while(!feof($file))
{
echo fgets($file). "<br />";
}
// close the file
fclose($file);
?>כלומר פתחנו את הקובץ כתבנו את כולו שורה אחר שורה ולאחר מכן סגרנו אותו בסיום.