added read and write functions
Trying to finish the task
Beta version (may be final)