domains
file = xinput
predicates
start
reading(integer)
searching(integer,integer)
goal
clearwindow,
start.
clauses
start:-
openread(xinput,"data.txt"),
readdevice(xinput),
reading(1).
reading(LineNo):-
not(eof(xinput)),
readln(Line),
write(LineNo," ",Line),nl,
LL = LineNo + 1,
reading(LL).
reading(_):-
write("\nEnter Line No = "),
readdevice(keyboard),
readint(LineNo),
filepos(xinput,0,0),
readdevice(xinput),
searching(LineNo,1).
searching(LineNo,Num):-
not(eof(xinput)),
LineNo <> Num,
readln(Line),
NN = Num + 1,
searching(LineNo,NN).
searching(LineNo,Num):-
not(eof(xinput)),
readln(Line),
closefile(xinput),
openwrite(xinput,"Outputq6.txt"),
writedevice(xinput),
write(Line),nl,
closefile(xinput),
write("See file outputq6.txt").
searching(LineNo,Num):-
write("Enter line no. is outof file"),nl.