# Remove blank lines from a file

# Input file name is a string
inFileName = raw_input('Enter name of file: ')

# Opening an output file will always succeed
outFile = open('strippedFile.txt','w')

# Need to use try-except structure to open input
# files, since there might not be a file with that
# name in the folder where the program is being
# run. 
try:
    inFile = open(inFileName,'r')
except:
    print "Cannot open file",inFileName
    inFile = None

if inFile != None:
    # process that data
    inStr = None
    while inStr != '':
        inStr = inFile.readline()
        # strip method removes whitespace at beginning and end
        testStr = inStr.strip()
        # Only write a line of output if there is anything left after stripping
        if testStr != '':
            outFile.write(inStr)
        
    inFile.close()

outFile.close()



