Might be more efficient to walk the chars in line and do the replacement on the fly, like:
int l = line.length();
for(i=0;i<l;i++) {
  char c = line.charAt(i);
  if( c == ' ' ) out.append( '\t' ) else out.append (c );
}
Would be worth testing to see if this is faster/slower than the above; it may well be slower.