input file input txt input readlines for in pat split ans for in if pa

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
input = file("input.txt", "r")
f = input.readlines()
for l in f:
pat = l.split()[0]
ans = []
for q in f:
if pat in q.split(' '):
ans.append(q)
if(len(ans) > 100):
out = file("%s.result" % pat, "w")
out.write("".join(ans))
out.close()