Checking for newline at EOF in modules.file.append()

This patch makes sure that a newline is present at end of file before appending.

In files not ending with a newline, it avoids ending with the last original line mixed up with the first appended line.