title: Returning value line by line
body: <p>I've got two classes:</p>
  
  <pre><code>public class SwimmingWorkout implements Workout {
  
      @Override
      public String getWorkout() {
          File fr = new File("swimmingWorkout_beginner.txt");
  
          Scanner sc = null;
          try {
              sc = new Scanner(fr);
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
  
          String val = "";
          while (sc.hasNextLine()) {
              val = val + sc.nextLine();
          }
  
          sc.close();
          return val;
      }
  }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>public class MainApp {
  
      public static void main(String[] args) {
          ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
  
          Workout workout = context.getBean("myWorkout", Workout.class);
          System.out.println(workout.getWorkout());
          context.close();
      }
  
  }
  </code></pre>
  
  <p>After running I have got all lines from file printed in one line. What I want to do is to return <code>val</code> value with each line printed in new line, not in one. How can I do this?</p>