Fixed bug with leftover line handling

Fixing a bug in the filter script for cleaning up test result file.