Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
How can I get the value from a string and write it in an output text file more than one time with it making new lines every time?

How can I get the value from a string and write it in an output text file more than one time with it making new lines every time? So I am trying to make a demo for how to save like user input in HTML to a text file using javascript, but I am not trying to do it at the moment, I am trying to do the same thing but from the console user input using readline-sync, the problem isn't in the module or anything else, the problem is when I for example type 'test' in the console it saves 'test' to a text file, but when I do the same process with another word, let's say 'hello' it removes 'test' and writes 'hello', I tried using the \n function but it didn't help, the code is down below:

const fs = require('fs')
const readline = require('readline-sync');
var userinput = 0;
userinput = readline.question(`test\n`);
fs.writeFile('Output.txt', userinput + "\n", (err) => {
      
    if (err) throw err;
})
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!