Fix some bugs with empty file scanning.