fix empty file handling