function encrypt(filein,fileout)

%*****************************************************************************80
%
%% encrypt() applies the CRYPTO function to a text file.
%
%  Discussion:
%
%    ENCRYPT 
%      with no arguments prompts for a input file name.
%    ENCRYPT inputfilename
%      encrypts the text in the input file and displays the results.
%    ENCRYPT inputfilename outputfilename
%      stores the encrypted text in the output file.
%
%    See also CRYPTO.
%
%  Licensing:
%
%    Copyright 2014 The MathWorks, Inc.
%
%  Author:
%
%    Cleve Moler
%
%  Reference:
%
%    Cleve Moler,
%    Numerical Computing with MATLAB,
%    SIAM, 2004,
%    ISBN13: 978-0-898716-60-3,
%    LC: QA297.M625,
%    ebook: https://www.mathworks.com/moler/chapters.html
%
if nargin < 1
   filein = input('Input file = ','s');
end
fin = fopen(filein);

if nargin == 2
   fout = fopen(fileout,'w');
else
   fout = 1;
end

while ~feof(fin)
   s = fgetl(fin);
   t = crypto(s);
   fprintf(fout,'%s\n',t);
end

fclose all;
