handle empty files correctly