write and read methods with dialog