Was completely wrong before, but fixed error by writing bytes instead of
stupidly thinking (write) handles byte-streams.