The first file looks something like this:

```
writing
writing
writing 
writing
eating
eating 
eating
doing
doing
doing
...

```

The second file looks this way:

```
writing write wrote written
eating eat ate
doing do does done
...

```

So basically, I need to add words (word by word) from the second file to each line of a first file (sequentially one word per line) and save it in a third file which would look like this:

```
writing writing
writing write
writing wrote
writing written
eating eating
eating eat
eating ate
doing doing
doing do
doing does
doing done
...

```

I tried this code but it does not do the job:

```
infile = open("first.txt", 'r') # open file for reading
infile2 = open("second.txt", 'r') # open file for reading
outfile = open("third.txt","w") # open file for writing

line = infile.readline()
line2 = infile2.readline()      # Invokes readline() method on file
while line:
    outfile.write(line.strip(' ')+line2.strip("\n")+'\n')
    line = infile.readline()
    line2 = infile2.readline()

infile.close()
outfile.close()
infile2.close()

```