import sys
import os
import glob
directory_input = raw_input("path to base directory?")
directory = directory_input
for folder in glob.glob(os.path.join(directory,"savedrecs(*).txt")):
a = 0
for file in glob.glob(os.path.join(folder, "savedrecs(*).txt")):
a=sum(not line.strip() == "\n" for line in searchfile)
print a
This is the code I have, but the a=sum(not line.strip() == "\n" part doesn't work and the result is always zero.