bug fix in file scan and implement error message