Made write actually timeout fixes #2
Added writef function