added check for empty file