First I created a .txt file that had the same data that you entered in your original .txt file. I used the 'w' mode to write the data as you already know. I create an empty list as well that we will use to store the data, and later write to the output.txt file. 
output_write = [] 
with open('test.txt', 'w') as file_object:
    file_object.write('yellow.' + 'blue.' + 'purple.' + 'green')
    file_object.write('\nred.' + 'blue.' + 'red.' + 'purple')   
Next I opened the text file that I created and used 'r' mode to read the data on the file, as you already know. In order to get the output that you wanted, I read each line of the file in a for loop, and for each line I split the line to create a list of the items in the line. I split them based on the period in between each item ('.'). Next you want to get the second and third items in the lines, so I create a variable that stores index[1] and index[2] called new_read. After we will have the two pieces of data that you want and you'll likely want to write to your output file. I store this data in a variable called output_data. Lastly I append the output data to the empty list that we created earlier. 
with open ('test.txt', 'r') as file_object:
    for line in file_object:
        read = line.split('.')
        new_read = read[1:3]
        output_data = (new_read[0] + '.' + new_read[1])
        output_write.append(output_data)
Lastly we can write this data to a file called 'output.txt' as you noted earlier. 
with open('output.txt', 'w') as file_object:
    file_object.write(output_write[0])
    file_object.write('\n' + output_write[1])
    print(output_write[0])
    print(output_write[1])
Lastly I print the data just to check the output:
blue.purple
blue.red