printing with write instead of stdout