fixed lines counting in open file