Reading input file and removing unwanted lines