<div>Hi am successfully downloading my text files and writing them to local files  with either</div>
<div> </div>
<div><a href="ftp://ftp.retrlines('RETR">ftp.retrlines('RETR</a> ' + fl, fileObj.write)"</div>
<div> </div>
<div><a href="ftp://ftp.retrbinary('retr/">ftp.retrbinary('RETR</a> ' + fl, fileObj.write)</div>
<div> </div>
<div>However all my recieved (log) files have lost thier newline characters?</div>
<div> </div>
<div>Can anyone steer me in the right direction so my 'recieved log' files arent all jumbled into one line?</div>
<div> </div>
<div>(full code below) </div>
<div>any help appreciated :)</div>
<div>(excuse my newbie code copying ) </div>
<div> </div>
<div>Special thanks to the person/s whom originally made this code (found on google)</div>
<div> </div>
<div> </div>
<div><<<<<<<<<code starts</div>
<div> </div>
<div>
<p>import string<br>import os<br>from sets import Set<br>from ftplib import FTP<br>import time</p>
<p>def copyFTPFiles(serverName,userName,passWord,remotePath,localPath,deleteRemoteFiles=False,onlyDiff=False):<br>    """Connect to an FTP server and bring down files to a local directory"""
</p>
<p>    try:<br>        ftp = FTP(serverName)<br>    except:<br>        print "Couldn't find server"<br>        #print >>myLogger, "Couldn't find server"<br>    <a href="ftp://ftp.login(username,password/">
ftp.login(userName,passWord</a>)<br>    <a href="ftp://ftp.cwd(remotepath/">ftp.cwd(remotePath</a>)</p>
<p>    try:</p>
<p>        #print >>myLogger, "Connecting...",<br>        print "Connecting..."<br>        if onlyDiff:<br>            lFileSet = Set(os.listdir(localPath))<br>            rFileSet = Set(<a href="ftp://ftp.nlst/">
ftp.nlst</a>())<br>            transferList = list(rFileSet - lFileSet)<br>            #print >>myLogger,  "Missing: " + str(len(transferList)) + ' >>> ',<br>            print "Missing: " + str(len(transferList)),
<br>        else:<br>            transferList = <a href="ftp://ftp.nlst/">ftp.nlst</a>()<br>        delMsg = ""<br>        filesMoved = 0<br>        for fl in transferList:<br>            ttt = ''<br>            ttt = str(fl)
<br>            if string.find(ttt, '.') > 0 :<br>                print '\nCopying >>> ' + ttt</p>
<p>                # create a full local filepath<br>                localFile = localPath + fl<br>                grabFile = True<br>                if grabFile:<br>                    #open a the local file<br>                    fileObj = open(localFile, 'wb')
<br>                    # Download the file a chunk at a time using RETR<br>                    #ftp.retrbinary('RETR ' + fl, fileObj.write)<br>                    <a href="ftp://ftp.retrlines('retr/">ftp.retrlines('RETR
</a> ' + fl, fileObj.write)</p>
<p><br>                    # Close the file<br>                    fileObj.close()<br>                    filesMoved += 1</p>
<p>                # Delete the remote file if requested</p>
<p>                if deleteRemoteFiles:<br>                    <a href="ftp://ftp.delete(fl/">ftp.delete(fl</a>)<br>                    delMsg = " and Deleted"<br>                    #print >>myLogger,  " and Deleted"
</p>
<p>        #print >>myLogger,  "Files Moved" + delMsg + ": " + str(filesMoved)  + ' >>> ' + " On " + timeStamp()<br>        print "\nFiles Copied " + delMsg + ": " + str(filesMoved)
<br>    except:<br>        #print >>myLogger,  "Connection Error - " + timeStamp()<br>        print "Connection Error - "<br>    <a href="ftp://ftp.close/">ftp.close</a>() # Close FTP connection<br>
    ftp = None</p>
<p>copyFTPFiles("server","uname","pass","remoteDir","localDir")</p>
<p> </p>
<p>>>>>>>>code end</p></div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>