Add error checking to windows impl read and write