Reading and processing a file line by line