Added check for file corruption