%include "inc:util.imp"
%begin; !Take

%constinteger max = 1024*512
%bytearray b(1:max)
%string(255)file
%integer k,n=0,pos=0

%on 9 %start
  printstring("Done"); newline
  selectoutput(1)
  %for n = 1,1,pos %cycle
    k = b(n)
    %if k<' ' %then newline %else printsymbol(k)
  %repeat
  %stop
%finish

%routine buffer up(%integer k)
  pos = pos+1; b(pos) = k
%end

file = cliparam
file = substring(file,2,length(file)) %if charno(file,1)='/'
openoutput(1,file)
selectoutput(0)
prompt(""); set terminalmode(noecho!notermecho)
printstring("Ready"); newline
%cycle
  readsymbol(k); bufferup(k)
%repeat

%end
