0) { // Seeks on the file pointer where we want to continue reading is known fseek($file, $offset); $lines = []; while (!feof($file)) array_push($lines,fgets($file)); die(json_encode(array("offset" => ftell($file), "lines" => $lines))); } } // Locate the current position of the file read/write pointer fseek($file, -1, SEEK_END); // Add one to skip the very last "\n" in the log file die(json_encode(array("offset" => ftell($file)+1))); ?>