Question: The canonical way of using a `Selector` in java NIO is :

1. regist the a `ServerSocketChannel` with the `SelectionKey.OP_ACCEPT` event type .
2. invoke `select` method (which block the thread)in a loop method
3. then when a `OP_ACCEPT` event happened , and the relative `AcceptEventHandler` is invoked to accept a `SocketChannel`
4. then regist the accepted `SocketChannel` with the `SelectionKey.OP_READ` event type.
5. when a read event happend , the `ReadEventHandler` handle the inputs and then regist the `SocketChannel` with a `SelectionKey.OP_WRITE` event type.

My question is, why don't register three event type at once at the beginning? Does the sequence make any sense?

Answer: 
First, **file** is a predefined package; please don't use it for a variable name, or you may have trouble getting to some of the facilities. Try **my\_file** or just the C-language **fp** (for "file pointer").

After you write new information to the file, your position pointer (bookmark) is likely at the end of the file. Reading more will get you nowhere. You need to either close and reopen the file, or call fp.seek() to get to the desired location. For instance, **fp.seek(0)** will reset the pointer to the start of the file.
When it comes to reading and writing files in python, if you do not call the method `(filename).close()` after making a change to a file, it will not save anything to it because it thinks you're still a) writing to it or b) still reading it!

Hope this helps!