def selectCat2() : array = [] if(os.stat("Categories/category2.txt").st_size==0): tkMessageBox.showinfo("Error", "Empty category file. Game will now shutdown.") os.system("./killAllPython.sh") else: with open("Categories/category2.txt","r") as ins: lines = ins.readlines() for line in lines: words = line.split() for word in words: array.append(word) ChosenWord=random.choice (array) #open file which will save entries outf = open('Categories/category2.txt', 'w') #send each user entry into the file print>>outf, ' '.join(array) outf.close() outf = open('drawThis.txt', 'w') print >>outf, ChosenWord outf.close() os.system('./SendMessage.py') GamePlay.main()