pep8
using contextlib for with-statement
write method