Laurent_R has already posted a reply that covers important points I had wanted to make.
Let me say this in addition. You're trying to be helpful and that's very good, but it doesn't help to offer wrong advice. The reason I almost always post code as cut/pastes from command-line executions is that, in addition to providing a complete context for execution, the code is actually executed and so is known to be at least syntactically correct — and maybe even has a chance of being semantically correct.