Problem was that the terminal was not needed, and some nul bytes were to be read.
Doesn't work yet. I've got a headache and debugging doesn't help.