Fix statsForFile is undefined error

I modified wrong file in last commit. So resend this PR again.

Added hasOwnProperty in loop to avoid statsForFile variable getting non self-defined property.