facade the detail implementation of knn in knn.h and add open file failed check for output file