improve handling of input with empty lines