Is your program a console app?
Maybe I can help you,just want to know that where is your code?
Pascal or delphi?
I made one console app in pascal
program text_files;
uses crt;
var FromFile,ToFile :text;
i,num:byte;
begin
clrscr;
(*we create two files*)
assign(FromFile,'c:\From.txt');
assign(ToFile,'c:\To.txt');
rewrite(FromFile);
rewrite(ToFile);
randomize;
(*ok,let's write some lines to the From.txt*)
for i:=1 to 20 do begin
writeln(FromFile,random(100)+1);
end;
close(FromFile);
(*we write only the odd numbers to the To.txt*)
reset(FromFile);
while not eof(FromFile) do begin
readln(FromFile,num);
if num mod 2 = 1 then writeln(ToFile,num);
end;
(*last,close them*)
close(FromFile);
close(ToFile);
writeln('Press enter to quit.');
readln;
(*created by FlamingClaw 2010.01.16*)
end.