Write newline to the end of file if last char is not newline