I am new to Scala and I need to read the contents of a text file in a line while deleting certain lines. The lines to be deleted can be identified using a substring. I could find the following solution that almost works, the only problem is that new lines are deleted:
val fileAsFilteredString = io.Source.fromFile("file.txt").getLines.filter(s => !(s contains "filter these")).mkString;
How to save newlines?
source share