handle IOErrors in open(file)