Hi,
it depends on whether problem has multiple input data or not.
Input file always appears on input stream - it is up to you, whether you cache whole answer and then write it to the output stream, or whether you write some piece of answer every time you receive piece of input data.
For single input data judging looks like this:
INPUT-FILE >> YOUR-PROGRAM >> JUDGE
In this case if wrong answer is found, your program will be terminated.
For multiple data:
LOOP {
INPUT-FILE >> YOUR-PROGRAM >> TEST-CASE-JUDGE
}
MASTER-JUDGE
In this case, if test-case-judge gets wrong answer, program will be terminated and will start again for the next test case. In the end, master-judge decides if solution can be accepted or not.