# -*- coding: utf-8 -*-
"""
Created on Mon Dec 05 12:56:15 2016

@author: klaas
"""
import os #filenames

folder = 'Masters' #put all the replay files here
Handle = 'IsHuman: True' #Search for this in the replay file

filenames = os.listdir(folder)
os.chdir( folder )
for filename in filenames:
    f1 = open(filename,"rb")
    with open('Output.txt', 'a') as f2: #output file
       lines = f1.readlines()
       for i, line in enumerate(lines):
           line = line.lstrip()            
           if line.startswith(Handle):
               print "player found"    
               f2.write(lines[i - 1])                
               f2.write(lines[i + 3])
               f2.write(lines[i + 7])
               f2.write(lines[i + 9])
    f1.close()