use write not dprintf for better compatibility