title: how to write a .csv file in "groovy" with multiple lines and no header is there(Expected to avoid append) in it?
body: <pre><code>class csv {
      static void main(String[] args) {
          def itemName
          def itemPrice
          def itemQty
          def list3 = []
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in))
          File file = new File("/Users/m_328522/Desktop/" + "invoicedetails.csv")
          file.createNewFile()
          println("Enter the number of items:")
          def noOfItems = br.readLine().toInteger()
          for (int i = 0; i &lt; noOfItems; i++) {
              println("Enter item " + (i + 1) + " details:")
              itemName = br.readLine()
              list3 &lt;&lt; itemName
              itemPrice = br.readLine().toDouble()
              list3 &lt;&lt; itemPrice
              itemQty = br.readLine().toInteger()
              list3 &lt;&lt; itemQty
              //println(list3)
              def asString = list3.join(",")
              file.append(asString +"\n")
              //println(asString)
              list3.remove(2)
              list3.remove(1)
              list3.remove(0)
              //println(list3)
          }
          println("invoicedetails.csv")
          println(file.text)
      }
  }
  </code></pre>