title: How to determine the end of a line with a Scanner?
body: <p>I have a scanner in my program that reads in parts of the file and formats them for HTML. When I am reading my file, I need to know how to make the scanner know that it is at the end of a line and start writing to the next line.</p>
  
  <p>Here is the relevant part of my code, let me know if I left anything out :</p>
  
  <pre><code>//scanner object to read the input file
  Scanner sc = new Scanner(file);
  
  //filewriter object for writing to the output file
  FileWriter fWrite = new FileWriter(outFile);
  
  //Reads in the input file 1 word at a time and decides how to
  ////add it to the output file
  while (sc.hasNext() == true)
  {
      String tempString = sc.next();
      if (colorMap.containsKey(tempString) == true)
      {
          String word = tempString;
          String color = colorMap.get(word);
          String codeOut = colorize(word, color);
          fWrite.write(codeOut + " ");
      }
      else
      {
          fWrite.write(tempString + " ");
      }
  }
  
  //closes the files
  reader.close();
  fWrite.close();
  sc.close();
  </code></pre>
  
  <p>I found out about <code>sc.nextLine()</code>, but I still don't know how to determine when I am at the end of a line.</p>