posix write instead of fwrite