Fix statsForFile is undefined error.

Added hasOwnProperty in loop to avoid statsForFile variable getting non self-defined property.