text = "" with open('wall.txt','r') as file: text = file.read() # Split the text into sentences sentences = text.split('.') # Find sentences without new lines sentences_without_newlines = [sentence for sentence in sentences if '\n' not in sentence] sentences_without_newlines = [sentence for sentence in sentences_without_newlines if len(sentence.split(' ')) > 3] # Print the results clean = "" for sentence in sentences_without_newlines: clean+=sentence.strip() + '.\n' with open('sentences.txt','w') as file: file.write(clean)