binary search done, and start writing and reading files