Не проходит последнее условие
package com.javarush.task.task19.task1922;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/*
Ищем нужные строки
*/
public class Solution {
public static BufferedReader input;
public static BufferedWriter output;
public static BufferedReader consoleReader;
public static List<String> words = new ArrayList<String>();
static {
words.add("файл");
words.add("вид");
words.add("В");
}
public static void main(String[] args) {
initStreams();
try {
while (input.ready()) {
String line = input.readLine();
String[] wordsInLine = line.split("\\s+");
int counter = 0;
for (String word : wordsInLine) {
if (words.contains(word)) {
counter ++;
}
}
if (counter == 2) {
System.out.println(line);
}
}
} catch (IOException e) {
e.printStackTrace();
}
closeStreams();
}
public static void initStreams() {
try {
consoleReader = new BufferedReader(new InputStreamReader(System.in));
String fileName = consoleReader.readLine();
input = new BufferedReader(new FileReader(fileName));
output = new BufferedWriter(new FileWriter(fileName, true));
} catch (IOException e) {
e.printStackTrace();
}
}
public static void closeStreams() {
try {
consoleReader.close();
input.close();
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}