fixing broken write method
updated example, added write example