Added cheking for empty lines
Added counting chars in input string