title: Reading from a text file and attempting to use printWriter to write to another results in a blank file
body: <p>My assignment is as follows:</p>
  <blockquote>
  <p>to write a program that reads the attached text file and writes out a separate text file (using your first initial and last name as the filename).  The new text file should contain all the same lines of text as the input file with the addition of a line number appended as the first character on the line.</p>
  <p>Ex: if your input line reads:</p>
  <p>this is a test</p>
  <p>your output should read</p>
  <ol>
  <li>this is a test</li>
  </ol>
  </blockquote>
  <p>I've written what I believe is mostly functional code- upon running it compiles and creates a new file to be written to, but that file is blank (contains 0 bytes). Reading up on the problem, I tried making sure my printWriter and input/output streams were closed/flushed. I'm not sure at this point whether something is wrong with my loop or if I'm calling the close methods in the wrong place. Any help is appreciated.</p>
  <p>Code is as follows:</p>
  <pre><code>package module6lecture;
  
  import java.util.Scanner;
  import java.io.FileNotFoundException;
  import java.io.PrintWriter;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  
  public class ReadWriteProgram {
  
  public static void main(String[] args) {
      try
      {
          FileInputStream fis = new FileInputStream(&quot;C:\\Users\\Reid\\Desktop\\Chapter11.txt&quot;);
          FileOutputStream fos = new FileOutputStream(&quot;C:\\Users\\Reid\\Desktop\\rulicny.txt&quot;);
          Scanner scan = new Scanner(fis);
          PrintWriter pw = new PrintWriter(fos);
          int lineNumber = 1;
          while(scan.hasNextLine());
          {
              String stringRead = scan.nextLine();
              pw.println(lineNumber + &quot;: &quot; + stringRead);
              lineNumber++;
          }
          pw.close();
      }
      catch(FileNotFoundException fnf)
      {
          System.out.println(&quot;Unable to find Chapter11.txt. Exiting...&quot;);
          fnf.printStackTrace();
      }
  }
  }
  </code></pre>
  <p>Disclaimer: I am a total newb.</p>