How to delete an empty line in a text file using wse (Wisescript)

This issue has been solved. See solution.
Uma's picture

Hi,
I have a simple text file with multiple lines. For example:

Text Line 1
Text Line 2
Text Line 3

I loop through this text file and depending on some situations, I have to delete "Text Line 2". When I do this, I want the text file to look like this:

Text Line 1
Text Line 3

and not like this:

Text Line 1

Text Line 3

What is the best way to do this? (I do not want to make back ups of the text file, etc)
Thanks!
Uma-

EdT's picture

Backups are the only way

Solution

You cannot remove a blank line within an existing text file in any elegant manner, as far as I am aware, if you plan to use Wisescript.
The way I do this is to read each line of the text file, decide whether I need this line, and if so, write it out to another text file. When the process is complete, I delete the original text file and substitute the new text file I have written.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

Uma's picture

Thanks!

Thanks!