close the output file datafile close(outputdata in aseem txt file before appeand operation ['aseem patel\ ''odisha state open university'data in aseem txt file after append operation ['aseem patel\ ''odisha state open university \ '' \ '' \ '' \ '' \ '' \ '' \ '' \ '' \ '' \ ' searching through file when you are searching through data in fileit is very common pattern to read through fileignoring most of the lines and only processing lines which meet particular condition we can combine the pattern for reading file with string methods to build simple search mechanisms for exampleif we wanted to read file and only print outlines which started with the prefix "from:"we could use the string method starts with to select only those lines with the desired prefixexamplefhand open('aseem txt',' 'print("data in aseem txt file"print(fhand read()print("data in aseem txt file after search"fhand open('aseem txt',' 'for line in fhandif line startswith('from:')print(lineoutputdata in aseem txt file fromzqian@osou ac in fromrjlowe@osou ac in frmstephen marquard@osou ac in fromlouis@osou ac in frozqian@osou ac in fromrjlowe@osou ac in data in aseem txt file after search fromzqian@osou ac in fromrjlowe@osou ac in page