Changed to properly handle running scripts from stdin.