<div dir="ltr">I have 2 different text files.<br>

<br>File1.txt contains:<br>

<pre style class=""><code><span class="">file
RAM
</span><span class="">Python</span><span class="">
parser</span></code></pre>

File2.txt contains:<br>

<pre style class=""><code><span class="">file
</span><span class="">1234</span><span class="">
program</span></code></pre>

I want to perform an union of these both files such that i get an output file3.txt which contains:<br>

<pre style class=""><code><span class="">file<br>RAM
</span><span class="">Python</span><span class="">
parser
</span><span class="">1234<br>program<br></span></code></pre>

<br><br>The program that i'm working on just combines two files. Any help on performing an union such that a keyword would not be repeated would be appreciated.<br><br><br>Code:<br>with open("C:\\File1.txt") as fin1: lines = fin1.readlines()<br>
with open("C:\\File2.txt") as fin2: lines.extend(fin2.readlines())<br>with open("D:\\file3.txt", "r+") as fout: fout.write('\n'.join(lines))</div>