I´m having some trouble with reading a file line-by-line, instead of reading the the file into memory. As of right now, I\'m reading the file into memory, and it works perfect.
Is this right for you?
with open(filename, 'r') as f: data = f.readlines() A = sum(float(line) for line in data) B = sum(float(line)**2 for line in data)