Write is now working, still needs to set errno on errors