/*
	The characters are read from the input file 
	and written in the output file
*/
copy(InputFile,OutputFile) :- 
	% Open the file for reading
	open(InputFile,read,InputStream),       

	% Open the file for writing
	open(OutputFile,write,OutputStream),       

	% Loop driving by failure 
    repeat, 
		get0(InputStream, Atom),    % read the character from input stream 
		process(OutputStream,Atom), % process the character: write in the output stream

	 % Close the streams
	close(InputStream),
	close(OutputStream),
	!.

/* Character of end of file */
process(_,-1) :- !. 

/* Process the atom */
process(OutputStream,Character) :-
		% Write the character
		put(OutputStream,Character), 
		% Loop driving by failure 
		fail. 
