files prints the string in the variable line which includes newline and then print adds another newlineresulting in the double spacing effect we see we could use line slicing to print all but the last characterbut simpler approach is to use the rstrip method which strips whitespace from the right side of string as followsfhand open('mbox-short txt'for line in fhandline line rstrip(if line startswith('from:')print(linecodewhen this program runswe get the following outputfromstephen marquard@uct ac za fromlouis@media berkeley edu fromzqian@umich edu fromrjlowe@iupui edu fromzqian@umich edu fromrjlowe@iupui edu fromcwen@iupui edu as your file processing programs get more complicatedyou may want to structure your search loops using continue the basic idea of the search loop is that you are looking for "interestinglines and effectively skipping "uninterestinglines and then when we find an interesting linewe do something with that line we can structure the loop to follow the pattern of skipping uninteresting lines as followsfhand open('mbox-short txt'for line in fhandline line rstrip(skip 'uninteresting linesif not line startswith('from:')continue process our 'interestingline print(linecodethe output of the program is the same in englishthe uninteresting lines are those which do not start with "from:"which we skip using continue for the "interestinglines ( those that start with "from:"we perform the processing on those lines we can use the find string method to simulate text editor search that finds lines where the search string is anywhere in the line since find looks for an occurrence