fix stdin and stdout on nodejs

newlines where not honored in stdout and hardcoded appended '\n' was breaking printf("foo");
stdin was just not working when running under nodejs. this way it just works for most cases (non interactive)