title: How to correctly download files using ftplib so line breaks are added for windows
body: <p>I have been using a very simple batch file to download millions of files from a UNIX ftp server for years</p>
  
  <pre><code>login
  passwd
  ascii
  prompt n
  cd to the right directory
  get some_file
  get another_file
  cd to the next directory
  repeat the pattern
  </code></pre>
  
  <p>The nice thing about this was that it was simple and all the files arrived with Window's line breaks so the files were ready to use with my existing programs.  Because of some changes in my router I had to write a Python script to pull the files - my first version of the script is very simple - but it works</p>
  
  <pre><code>for key in key_filings:
     for filing in key_filings[key]:
          remote_directory = '/foo/bar/' + key + '/' + filing['key_number']
          ftp.cwd(remote_directory)
          text_file = filing['txt']
          ftp.retrlines('RETR '+ text_file, open(save_dir + text_file,'w').writelines)
          hdr_file = filing['hdr']
          ftp.retrlines('RETR ' + hdr_file, open(save_dir + hdr_file,'w').writelines)
  </code></pre>
  
  <p>However, the files do not have any apparent line breaks.  The files are stored in a unix system.  Before when I downloaded the files using the Windows CMD shell the line breaks were just there.  I have tried sending the ASCII command but as expected that did not have any effect.  </p>
  
  <p>It is critical that I be able to have access to the line breaks that existed originally as some of my code processing is line based.</p>