title: Java - Code repeats itself in a loop
body: <p>I'm working on a program that gets a users input from a command line. However, when the program loops, it repeats some lines of code (shown below).</p>
  
  <p>My problem is, for every iteration of the loop past the first one, it skips the game title and goes straight to the score.</p>
  
  <p>How would I prevent this from happening?</p>
  
  <pre><code>p = System.out.print()
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>        for (int i = 0; i &lt;= 10; i++) {
              if( i == 0) {
                  p("Enter player: ");
                  playerName = scan.nextLine();
              }           
  
              try {       
                  gameName = "";
                  score = 0;
                  time = 0;
  
                  p("Enter game: ");
                  gameName = scan.nextLine();
  
                  p("Enter score: ");
                  score = scan.nextInt();
  
                  p("Enter time: ");
                  time = scan.nextInt();
  
                  Game game = new Game(gameName, score, time);
                  if (i == 0) {
                      textToPrint = playerName + "\r\n- - - - - - - - - - - - -\r\n" + game.getGame() + " : " + game.getScore() + " : " + game.getTime() + "\r\n";
                  } else {
                      textToPrint = game.getGame() + " : " + game.getScore() + " : " + game.getTime() + "\r\n";
                  }               
              } catch (InputMismatchException e) {
                  p("You must enter an integer!");            
              }
  
              try {
                  WriteFile data = new WriteFile("scores.txt");       
                  data.WriteToFile(textToPrint);
              } catch (IOException e) {
                  p("Something went wrong during printing: " + e.getMessage());
  
              }   
          }   
  </code></pre>
  
  <p>And it repeats here:</p>
  
  <pre><code>                p("Enter game: ");
                  gameName = scan.nextLine();
  
                  p("Enter score: ");
                  score = scan.nextInt();
  </code></pre>
  
  <p>So the output looks like this:</p>
  
  <pre><code>Enter game: Enter score:
  </code></pre>
  
  <p>Any ideas would be greatly appreciated!</p>
  
  <p>Thanks!</p>