%trace
domains
file = input;output
predicates
repeat
start
readfile
find(integer)
clauses
repeat.
repeat:-
repeat.
start:-
openread(input,"readfile.txt"),
readdevice(input),
readfile,
filepos(input,0,0),
readdevice(keyboard),
write("Enter the no::"),
readint(No),
readdevice(input),
find(No).
readfile:-
not(eof(input)),
readln(Line),
str_len(Line,Len),
write(Line," ",Len),
readfile.
readfile.
find(No):-
repeat,
not(eof(input)),
readln(Line),
str_len(Line,Len),
No=Len,
openwrite(output,"writefile.txt"),
writedevice(output),
write(Line),
closefile(output),
write("File successfully written").