tested write(), fixes #3