I had scenario where I have to delete the current line if I Have ';' at the end of current line and replace string in the previous line in the text file. Here is an example:
Prev line - I am Manish &
current Line - I went to college ;
Now I have to delete the current line as it has a ';' and replace '&' with ';' in the previous line.

First of all, show us what you have tried so far. The answer also depends on the format of your data. Are you processing a file line-by-line, or are you processing a list of lines where each list element is one line of text?

Also, instead of giving us the input and merely describing the output, show us exactly what the output should look like. This helps to avoid confusion/ambiguity. I'm guessing that you mean

Input:

    I am Manish &
    I went to college;

Output:

    I am Manish ;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.