Question: I have an html page that has a textarea form and when the user types into that textarea and presses submit, php writes the content of that textarea to a txt file.

When I insert something like this into the textarea

```
line1 what's up
line2
line3

```

it ends up writing to the txt file as so

```
line1 what\'s up

line2

line3

```

with extra whitespace and that extra slash. How can I fix this? Here is the php

```
$myFile = "all.txt";
$fh = fopen($myFile, 'a') or die("can't open file");

$stringData = $content."\n";
fwrite($fh, $stringData);
fclose($fh);

```

Answer: 
The extra newlines are likely caused by a difference in line endings between what's writing the file and what is reading the file.

Perhaps you can just use `"\n"` to end your lines.

The extra escape sequence for the single quote is magic quotes.

Consider this code:

```
<?php 

ini_set('magic_quotes_gpc', 'off');
$content = str_replace("\r\n", "\n");

```

Optionally, you can use the `PHP_EOL` constant which will match the host OS' line endings.
If you are retrieving the data from a textbox the data actually looks like

```
line1 what's up\r\n
line2\r\n
line3

```

so adding an extra `\n` on the end will add an additional line.

As for the `\'` this usually with happens with magic\_quotes enabled.
Doing a quick search for "magic\_quotes" in your `phpinfo()` will let you know if you have it turned on or not.