Hi i have a file contain some word , my requirement is to remove the matching word.If word is remove from between the line rest of the word below has to shifted up to avoid white space.

```
File.txt

medical_data01
medical_data02
medical_data
Census_data_10000_k.gen
Census_data_10000_k.gen_01
Census_data_10000_k.gen_02

```

If i remove `medical_data`
Output should come like this

```
medical_data01
medical_data02
Census_data_10000_k.gen
Census_data_10000_k.gen_01
Census_data_10000_k.gen_02

```

But my code output is coming like this

```
01
  02

    Census_data_10000_k.gen
    Census_data_10000_k.gen_01
    Census_data_10000_k.gen_02

File file = new File(
                RESOURCE_BUNDLE.getString("tested"));
        File temp = File.createTempFile("file", ".txt",
                file.getParentFile());
        String charset = "UTF-8";
        String delete = "medical_data";
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(new FileInputStream(file),
                        charset));
        PrintWriter writer = new PrintWriter(
                new OutputStreamWriter(new FileOutputStream(temp),
                        charset));
        String currentLine;
        while ((currentLine = reader.readLine()) != null) {
            currentLine = currentLine.replace(delete,"");
            if (currentLine.equals("")) {

            } else
                writer.println(currentLine);
        }
        writer.close();
        reader.close();
        file.delete();
        temp.renameTo(file);

```