String line;
BufferedReader input = new BufferedReader(new FileReader(in));
PrintStream output = new PrintStream(new FileOutputStream(out, false));
// Initialization of input and output omitted
while((line = input.readLine()) != null) {
// apply all filters
for(int i = 0; i < filters.length; i++) {
line = filters[i].filter(line);
}
if(line != null) {
output.println(line);
}
}