# Program to remove empty lines from any file

# User enters name of file
inFileName = raw_input("Enter name of input file: ")

try:
    # Try to open it; might cause a crash if
    # not in try-except construction. 
    inFile = open(inFileName, "r")
except:
    # Gets here if we cannot open the file
    print "Cannot find file",inFileName
    inFile = None



if inFile != None:
    outFileName = raw_input("Enter name of output file: ")
    # It's always possible to open a file for writing
    # If it doesn't exist it gets created
    outFile = open(outFileName, "w")

    # Typical loop to read a file
    inStr = inFile.readline()  # Read first line
    while inStr != "":  # Empty string means end of file
        # Strip out leading and trailing whitespace
        testStr = inStr.strip()
        if testStr != "":  # Only keep line if anything is left
            outFile.write(inStr)
        inStr = inFile.readline()


    inFile.close()
    outFile.close()
    

