Prevent infinite loop when input file is empty

This is to resolve #6