Handle error in determining file encoding