Fixed read command, no memory leaks, and it fails most of the test cases that it should fail. Only thing left is the subshell.