Fix problem with adding multiple new line separators

Both inside file and at the end