i have a problem in file handling. i have to read a file for a text pattern, and whenever it is encountered, i have to insert a line of text before it, and a line of text after the pattern. how do i go about it?
You read one file and write a second file. When you read text that doesn't match the pattern, you copy it unchanged to the second file. When you do match the pattern, you write the data you describe in your message. Finally, you rename the original file, rename the new file to the original name, and delete the original file.