Okay, let me give you another example for the STDIN and STDOUT usage.
In PHP you use these two idioms:
$input = fgets(STDIN);
fwrite(STDOUT, $output);
When from the commandline you utilize them as such:
cat "input.txt" | php script.php > "output.txt"
php script.php < input.txt > output.txt
echo "input..." | php script.php | sort | tee output.txt
That’s all these things do. Piping in, or piping out. And the incoming parts will appear in STDIN, whereas your output should go to STDOUT. Never cross the streams, folks!