Here is the input text file I am working with: <https://gist.github.com/TestAcc7777/5983147>

In the text file, each line after the initial few contains 'CORE X', where X is a number from 1 to 64. Some of the lines containing 'CORE X' also contain either 'V3' or 'V4. 

For each value of X, I want to output the lines containing 'CORE X' and that also only contain one of 'V3' or 'V4' - which one to is be decided using a random number generator.

I've written the following in Python 3, and incorporated some regex, to write all lines containing 'CORE X' except those containing the rejected 'V' fragments:

```
import re
import random

tri = open(input("Input File: "))
tro = open(input("Output File: "),'w')

for line in tri.readline():
    for i in [1,65,1]:
        if random.random()>0.5:
            q = 4
        else:
            q = 3
        if re.search(r'CORE\s'+str(i), line):
            if re.search(r'V', line):
                if re.search(r'V'+str(q), line):
                    tro.write(line)
            else:
                tro.write(line)

```

When I run the program however, it seems to finish rather quickly and the output file is empty. I still rather inexperienced with Python and programming in general, so any help in getting my program to help will be greatly appreciated.