Fixed memory leak.
Piped stdout to file, fixing encoding issues.

- Also, passed in host and cookie.
- Passed in the correct script name.
Added command-line flags for CGI script.

- RECORD_FOLDER and replayserver.