Código Delphi
[-]procedure TForm1.Button1Click(Sender: TObject);
var Input, Output: TextFile; Line: string;
begin
AssignFile(Input, Edit1.Text);
{$i-}Reset(Input);{$i+}
if IoResult <> 0 then Exit;
AssignFile(Output, Edit1.Text + 'o');
ReWrite(Output);
while not EOF(Input) do
begin
ReadLn(Input, Line);
while (Line <> '') and (Line[1] = ' ') do
Delete(Line, 1, 1);
if (Line <> '') and
(((Line[3] in ['0'..'9']) and (Line[11] = ' ')) or
((Copy(Line, 1, 9) = 'OFICINA: ') or (Copy(Line, 1, 9) = 'SINIESTRO'))) then
WriteLn(Output, Line);
end;
CloseFile(Output);
CloseFile(Input);
end;
Me tome la libertad de optimizarlo un poquito
; creo que tu función no tomaba en cuenta la última línea.
Espero te sea de utilidad.
Saludos