fixed to deal with empty lines