reading lines from files with a loop