def splitfile(fname): text_file = open(fname, "r") halfText = text_file.len()/2 firstHalf = text_file.read(halfText) secondHalf = text_file.read(halfText) new_text_file1 = open(fname+"1", "n") text_file1.write(firstHalf) new_text_file2 = open(fname+"1", "n") text_file1.write(secondHalf) new_text_file1.close() new_text_file2.close() def getInput(): fname = raw_input("Enter the filename of the text file you want to split in half\n\n") checkInput(fname) def checkInput(fname): if fname != "": splitfile(fname) else: prob = raw_input("\n\nTry again?\nY/N") if prob.lower() == "y": getInput() elif prob.lower() == "n": print "goodbye" getInput() =============================================================== Traceback (most recent call last): File "C:\Documents and Settings\Yansky\workspace\test\test.py", line 28, in getInput() File "C:\Documents and Settings\Yansky\workspace\test\test.py", line 16, in getInput checkInput(fname) File "C:\Documents and Settings\Yansky\workspace\test\test.py", line 20, in checkInput splitfile(fname) File "C:\Documents and Settings\Yansky\workspace\test\test.py", line 2, in splitfile text_file = open(fname, "r") IOError: [Errno 2] No such file or directory: 'read_it.txt\r'