Writing and reading text files in python

The following code will read a text file, remove blank lines from it, and save it again as another file.

with open("test.txt", "r") as lines:
    with open("newtest.txt", "w") as newfile:
        for line in lines:
            if not line == '\n':
                newfile.write(line)