I have a text file with empty lines. The meaning of lines that have nothing on them and just take up space.
It looks like this:
The quick brown fox jumped over the lazy dog
and I need it to look like this:
The quick brown fox jumped over the lazy dog
How to delete these empty lines and take only lines with contents and write them to a new file?
Here is what I know how to do this:
$file = fopen('newFile.txt', 'w'); $lines = fopen('tagged.txt'); foreach($lines as $line){ /* check contents of $line. If it is nothing or just a \n then ignore it. else, then write it using fwrite($file, $line."\n");*/ }
source share