Move write_all() from net.c to fd.c.