What are common pitfalls when reading and processing long text files in PHP?

One common pitfall when reading and processing long text files in PHP is running out of memory due to trying to read the entire file into memory at once. To avoid this, it's better to read the file line by line or in chunks. This can be achieved using functions like `fgets()` or `fread()`.

$filename = 'example.txt';
$handle = fopen($filename, 'r');

if ($handle) {
    while (($line = fgets($handle)) !== false) {
        // Process each line here
    }
    
    fclose($handle);
} else {
    echo 'Error opening the file.';
}