I recently learnt that to read properly from a text file we use
while(file>>var1>>var2){ //do stuff with data }
instead of