added a check for an empty file