diff --git a/lib/file-control.php b/lib/file-control.php
index 79a73ee..d1dc86e 100644
--- a/lib/file-control.php
+++ b/lib/file-control.php
@@ -112,11 +112,11 @@ if ($_GET['action']=="load") {
if($encoding=="") {
$encoding="UTF-8";
}
- // Left trim any \r from start of text after setting HTML entities on it according to encoding
- $loadedFile = ltrim(htmlentities($loadedFile,ENT_COMPAT,$encoding),"\r");
- if (substr($loadedFile,0,1) == "\n") {
- $loadedFile = "
".substr($loadedFile,1);
- }
+ // Get content and set HTML entities on it according to encoding
+ $loadedFile = htmlentities($loadedFile,ENT_COMPAT,$encoding);
+ // Remove \r chars and replace \n with carriage return HTML entity char
+ $loadedFile = preg_replace('/\\r/','',$loadedFile);
+ $loadedFile = preg_replace('/\\n/','
',$loadedFile);
echo '