title: Android Studio Java display text file contents in new lines
body: <p>Im creating a weight tracking app where the user inputs their weight clicks a save button and then the weight is saved. There is also a load button that loads all the previous inputs. The problem I'am having is that once load is clicked it does load up the weights on the screen but it does it all in one line other than a separate line for each.</p>
  <p>I have checked the text file and all the weights are stored in a line each so there's no problem in the function that stores the inputs.</p>
  <p>Here is the code for the `weight tracker</p>
  <pre><code>package com.example.workouttracker;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  import java.io.BufferedReader;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  
  public class WeightTracking extends AppCompatActivity {
      private static final String FILE_NAME = &quot;WeightTracking.txt&quot;;
  
  
      EditText mEditText;
      EditText mEditText2;
      private Button button_back_home;
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_weight_tracking);
  
          mEditText = findViewById(R.id.weight);
          mEditText2 = findViewById(R.id.weight2);
  
          button_back_home=(Button) findViewById(R.id.button_back_home);
          button_back_home.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  homePage();
              }
              private void homePage(){
                  startActivity(new Intent(getApplicationContext(),MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
              }
          });
  
      }
      public void save(View v) {
          String text = mEditText.getText().toString();
          FileOutputStream fos = null;
  
          try {
              fos = openFileOutput(FILE_NAME, MODE_APPEND);
              fos.write((text + &quot;kg's\n&quot;).getBytes());
  
  
              mEditText.getText().clear();
              Toast.makeText(this, &quot;Saved to &quot; + getFilesDir() + &quot;/&quot; + FILE_NAME,
                      Toast.LENGTH_LONG).show();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          } finally {
              if (fos != null) {
                  try {
                      fos.close();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          }
      }
      public void load(View v) {
          FileInputStream fis = null;
          try {
              fis = openFileInput(FILE_NAME);
              InputStreamReader isr = new InputStreamReader(fis);
              BufferedReader br = new BufferedReader(isr);
              StringBuilder sb = new StringBuilder();
              String text;
              while ((text = br.readLine()) != null) {
                  sb.append(text);
                  sb.append('\n');
              }
              mEditText2.setText(sb.toString());
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          } finally {
              if (fis != null) {
                  try {
                      fis.close();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          }
      }
  }
  </code></pre>
  <p>Someone know's how to get it to load each weight line by line?
  Thanks</p>
  <p>`</p>