For example, this is a sample and simplified text file:
word1 word2 word3 word1 word1 word2
word1 word2 word3 word4
I want a regex that could remove anything after the second word, in this instance, word2. And if possible to remove the lines with empty space too. Would something of that sort be possible?