import java.io.*;
import java.util.*;

public class ch10ex5 {
  public static void main(String args[]) {
    if(args.length == 0) {
      System.out.println("Usage: ch10ex5 filename word1 word2 ...");
      return;
    }
    try {
      DataInputStream in =
        new DataInputStream(
          new BufferedInputStream(
            new FileInputStream(args[0])));
      Vector v = new Vector();
      String s;
      while((s = in.readLine()) != null)
        v.addElement(s);
      for(int i = 0; i < v.size(); i++)
        for(int j = 1; j < args.length; j++) {
          s = (String)v.elementAt(i);
          for(int k = 0; k < s.length(); k++)
            if(s.regionMatches(k, args[j], 0, args[j].length()))
              System.out.println(s);
        }
    } catch(FileNotFoundException e) {
      System.err.println("File not found");
    } catch(IOException e) {
      System.err.println("IO error");
    }
  }
}
