worst and dirtiest code ever to read input file working