Add Read/Write function

Just add some logic in the code, nothing tested yet.