SplFileObject read file

php spl SplFileObject
$file = new SplFileObject("file.txt");
while (!$file->eof()) {
    echo $file->fgets();
}
function lines($filename) {
    $file = new SplFileObject($filename);
    while (!$file->eof()) {
        yield $file->fgets();
    }
}

foreach (lines('German.txt') as $line) {
    echo $line;
}