#!/usr/bin/php 5000) { // flush buffer before adding flushwords($nextbuffer); $nextbuffer = ''; $buffwords = 0; } $nextbuffer .= $line."\n\n"; $buffwords += $linewords + 2; // echo "entry {$nextline} had {$linewords}, current total {$buffwords}\n"; } while($nextline < count($lines)); flushwords($nextbuffer); $nextbuffer = ''; $buffwords = 0; // All flushed // Write the final output file_put_contents($_SERVER['argv'][1].'.en.deepl.srt', $output_buffer);