forgot to put stdin = sub.PIPE
fixed some comments as well