fix bug of empty file

if an input file has no data, system will crash