At the very least, I'd recommend changing
result += line + "\n";
to a StringBuilder.
resultBldr.append(line).append("\n");
This avoids creating a new string object--a bigger and bigger and bigger and bigger string object!--on each line.
Also, you should definitely write your output to the file line by line. Don't accumulate all that text and then output it.
In other words, in this situation, complete separation between your read
and write
functions is not recommended.