import sys

# get hits from miranda scans
with open(sys.argv[1]) as infile1:
    with open(sys.argv[2], "w") as outfile:
        for line1 in infile1:
            if "%" in line1 and "Forward:" not in line1:
                outfile.write(line1)

import sys

# get hits from miranda scans
cap = ""
with open (sys.argv[1]) as infile1:
    for line1 in infile1:
        line1 = line1.strip()
        if "%" in line1 and "Forward:" not in line1:
            #print(line1)
            cap = cap + line1 + "\n"
allregnettf = open(sys.argv[2], "w")
allregnettf.write(cap)
allregnettf.close()

--- 
+++ 
@@ -1,13 +1,8 @@
 import sys
 
 # get hits from miranda scans
-cap = ""
-with open (sys.argv[1]) as infile1:
-    for line1 in infile1:
-        line1 = line1.strip()
-        if "%" in line1 and "Forward:" not in line1:
-            #print(line1)
-            cap = cap + line1 + "\n"
-allregnettf = open(sys.argv[2], "w")
-allregnettf.write(cap)
-allregnettf.close()
+with open(sys.argv[1]) as infile1:
+    with open(sys.argv[2], "w") as outfile:
+        for line1 in infile1:
+            if "%" in line1 and "Forward:" not in line1:
+                outfile.write(line1)
Write output on the file.
