I have some code to clean files line by line in perl. One part of the code checks lines for spaces and removes those spaces. Based on my logic, it should also remove lines that are just blank lines, but it does not.

```
$file = "myfile.txt";  
open (IN, $file) || die "Cannot open file ".$file." for read";       
@lines=<IN>;    
close IN;  

open (OUT, ">", $file) || die "Cannot open file ".$file." for write";  
foreach $line (@lines)  
{    

    #removes all spaces from lines and but won't remove empty lines (it should).
    $line =~ tr/ //d;
    #remove double quotes from file
    $line =~ s/\x22//g;

   print OUT $line;    
}    
close OUT; 

```

How can I add to this code to remove all lines that are just empty lines? To turn this:

```
This is "line 1".
This is "line 2".

This is "line 4".
This is "line 5".

```

into this:

```
Thisisline1.
Thisisline2.
Thisisline4.
Thisisline5.

```