title: I am trying to write my Object into a Json File after converting it in JsonObject but it is not getting written
body: <p>Here is my data (value in myRecords) :</p>
  <pre><code>[Record{Purpose='Medical ', ID='9215524400  ', UpdateTime='2020-10-14', Checkin='2020-10-14'},...] 
  </code></pre>
  <p>Here is my code :</p>
  <pre><code>        private FileWriter file;
          JSONArray jsonArr = new JSONArray(myRecords);
          for (int i = 0; i &lt; jsonArr.length(); i++) {
              JSONObject jsonObj = jsonArr.getJSONObject(i);
              file = new FileWriter(&quot;NewFile.json&quot;);
              file.write(String.valueOf(jsonObj));
            }
  </code></pre>
  <p>I am not getting any errors but nothing is getting written into the file.</p>