Question: can someone please tell me what is going wrong?

I am trying to create a basic login page and that opens only when a correct password is written

```
<html>
<head>
<script>
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
  {
  alert("First name must be filled out");
  return false;
  }
var x=document.forms["myForm"]["fname2"].value;
if (x==null || x=="")
  {
  alert("password must be filled out");
  return false;
  }
}

function isValid(myNorm){
var password = myNorm.value;
if (password == "hello_me")
{
return true;
}
else 
{alert('Wrong Password')
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="helloworld.html" onsubmit="return !!(validateForm()& isValid())" method="post">
Login ID: <input type="text" name="fname"> <br />
<br>

Password: <input type="password" name="fname2" > <br />

<br />
<br />

<input type="submit" value="Submit">
<input type="Reset" value="clear">
</form>
</body>
</html>

```

Answer: 
try this

```
BufferedWriter writer = new BufferedWriter(new FileWriter("result.txt"));       
    for (String element : misspelledWords) {
        writer.write(element);
        writer.newLine();
    }

```

Adding line separator at the end (like "\n") should work on most OS,but to be on safer side 
you should use **System.getProperty("line.separator")**
Open your file in append mode like this
 `FileWriter(String fileName, boolean append)` when you want to make an object of class `FileWrite`

in constructor.

```
 File file = new File("C:\\Users\\Izak\\Documents\\NetBeansProjects\\addNewLinetoTxtFile\\src\\addnewlinetotxtfile\\a.txt");
    try (Writer newLine = new BufferedWriter(new FileWriter(file, true));) {
       newLine.write("New Line!");
       newLine.write(System.getProperty( "line.separator" ));
    } catch (IOException e) {

    }

```

Note:

> 
> "**line.separator**" is a Sequence used by operating system to separate lines
>  in text files
> 
> 
> 

source:
<http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html>