// Check that we have enough command line arguments and // if not abort with an error message. if (args.size != 2) punt("command line is: search pattern file"); // Move arguments to variables with better names string pattern = args[0]; string fileName = args[1]; // Open a file to read, and then loop through each line. file f = fileOpen(fileName, "r"); // "r" is for read for (line in f.readLine()) { // The line.find call returns the starting index of the // pattern in the line, or -1 if not found. if (line.find(pattern) >= 0) prin(line); // Line already has end of line so prin }