Add write_hostname method