No newline character at end of file even after writing it
<pre><code># Create strings for preparation of file writing
s = ";"
seq = (risd41Email, risd41Pass, rimsd41Email, rimsd41Pass);
textString = s.join(seq);

# Create file, write contents, move to usertxtfiles dir
with open(filename, "w") as text_file:
    text_file.write(str(textString))
    text_file.write('\n')

os.rename(fileMigPath, fileDestPath)
</code></pre>

<p>I have the above code that clearly writes a newline to the file I am editing. When I try to use the file another script does not execute the line because there is no newline character at the end of the file. If I copy the file and then open it in vi and then save it, vi adds a newline character and the line of the file executes properly. If I run diff between the file that wasn't saved in vi versus the one that was I get the message that the difference is no newline at end of file. I am using Python 2.7.12 on Ubuntu server Xenial. </p>

<p>Try that:</p>

<pre><code>    text_file.write('\n\n')
</code></pre>

<p>This should work!</p>

python