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.
def read(filename):
with open(filename, 'r') as f: #open the file
A = sum(float(line) for line in f)
f.seek(0)
B = sum(float(line)**2 for line in f)
print(B)