fix error when input is an empty file and add tests to avoid regressions. closes #126