Buggy code:
att = att . replace ( "&lt;ref&gt;{{" , "<seq2seq4repair_space>" ) ; att = att . replace ( "-" , "<seq2seq4repair_space>" ) ; att = att . replace ( "_" , "<seq2seq4repair_space>" ) ; att = att . replace ( ":" , "<seq2seq4repair_space>" ) ; att = att . replace ( "+" , "<seq2seq4repair_space>" ) ; att = att . replace ( "'" , "<seq2seq4repair_space>" ) ; att = att . replace ( "|" , "<seq2seq4repair_space>" ) ; Pattern p = Pattern . compile ( "(.+)<seq2seq4repair_space>of<seq2seq4repair_space>(.+)" ) ; Matcher m = p . matcher ( att ) ; if ( m . find ( ) ) { String [ ] tmp = att . split ( "\\s+" ) ; for ( int j = 0 ; j < ( tmp . length ) ; j ++ ) { if ( ( ( j > 0 ) && ( tmp [ j ] . equals ( "of" ) ) ) && ( ( j + 1 ) < ( tmp . length ) ) ) { String tmpo = tmp [ ( j - 1 ) ] ; tmp [ ( j - 1 ) ] = tmp [ ( j + 1 ) ] ; tmp [ ( j + 1 ) ] = tmpo ; tmp [ j ] = "" ; } } att = "" ; for ( int j = 0 ; j < ( tmp . length ) ; j ++ ) { att += tmp [ j ] ; } } voc [ i ] = att ; vocabulary . removeFirst ( ) ; } for ( int i = 0 ; i < wordNum ; i ++ ) { String att = voc [ i ] ; String [ ] mult = att . split ( "\\s+" ) ; if ( ( mult . length ) > 1 ) { voc [ i ] = "" ; for ( int j = 0 ; j < ( mult . length ) ; j ++ ) { voc [ i ] += mult [ j ] ; } } } LinkedList < String > changelist = new LinkedList < String > ( ) ; HashMap < String , String > translate = new HashMap < String , String > ( ) ; int attributes_to_compare = wordNum - ignore ; int c = 0 ; int changes = 0 ; for ( int i = 0 ; i < attributes_to_compare ; i ++ ) { String att = voc [ i ] ; Pattern p3 = Pattern . compile ( ".+[0-9]" ) ; Matcher m3 = p3 . matcher ( att ) ; if ( ! ( translate . containsKey ( att ) ) ) { translate . put ( att , att ) ; } if ( ( ( ( att . length ( ) ) < ( java_key_cleaner . number_of_char ) ) && ( ( att . length ( ) ) > 4 ) ) && ( ! ( m3 . find ( ) ) ) ) { for ( int j = 0 ; j < wordNum ; j ++ ) { String check = voc [ j ] ; String first4 = "" ; if ( ( att . length ( ) ) > 3 ) { first4 = att . substring ( 0 , 4 ) ; } Pattern p = Pattern . compile ( first4 ) ; Matcher m = p . matcher ( check ) ; if ( ( ( m . find ( ) ) && ( ( ( check . length ( ) ) - 2 ) < ( att . length ( ) ) ) ) && ( ( att . length ( ) ) < ( ( check . length ( ) ) + 2 ) ) ) { String last = check . substring ( ( ( check . length ( ) ) - 1 ) ) ; Pattern p2 = Pattern . compile ( ".+[0-9]" ) ; Matcher m2 = p2 . matcher ( check ) ; if ( ( ! ( translate . containsKey ( check ) ) ) && ( ! ( m2 . find ( ) ) ) ) { int diff = distance ( att , att . length ( ) , check , check . length ( ) ) ; if ( diff < 2 ) { translate . put ( check , att ) ; changelist . add ( ( ( check + "\t" ) + att ) ) ; changes ++ ; } } } } } c ++ ; } for ( int i = 0 ; i < wordNum ; i ++ ) { String att = voc [ i ] ; if ( translate . containsKey ( voc [ i ] ) ) { voc [ i ] = translate . get ( voc [ i ] ) ; } } HashMap < String , String > translationToken = new HashMap < String , String > ( ) ; for ( int i = 0 ; i < wordNum ; i ++ ) { String att = voc [ i ] ; if ( ! ( translationToken . containsKey ( voc [ i ] ) ) ) { translationToken . put ( voc [ i ] , orgVoc [ i ] ) ; } } for ( int i = 0 ; i < wordNum ; i ++ ) { String att = voc [ i ] ; voc [ i ] = translationToken . get ( att ) ; } if ( outputStats ) { try { <START_BUG> FileWriter fw = new FileWriter ( "debug_attribute_changes.txt" ) ; <END_BUG> BufferedWriter out = new BufferedWriter ( fw ) ; out . write ( ( ( "A<seq2seq4repair_space>total<seq2seq4repair_space>of<seq2seq4repair_space>" + ( translate . size ( ) ) ) + "<seq2seq4repair_space>keys<seq2seq4repair_space>where<seq2seq4repair_space>changed<seq2seq4repair_space>due<seq2seq4repair_space>to<seq2seq4repair_space>misspellings<seq2seq4repair_space>or<seq2seq4repair_space>formatting<seq2seq4repair_space>errors" ) ) ; out . newLine ( ) ; int numOfChangesInJSON = 0 ; for ( int i = 0 ; i < wordNum ; i ++ ) { if ( ! ( orgVoc [ i ] . equals ( voc [ i ] ) ) ) { numOfChangesInJSON += numOcc [ i ] ; } } out . write ( ( ( "A<seq2seq4repair_space>total<seq2seq4repair_space>of<seq2seq4repair_space>" + numOfChangesInJSON ) + "<seq2seq4repair_space>keys<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>JSON<seq2seq4repair_space>file<seq2seq4repair_space>was<seq2seq4repair_space>corrected.\nThese<seq2seq4repair_space>words<seq2seq4repair_space>changed<seq2seq4repair_space>where<seq2seq4repair_space>the<seq2seq4repair_space>following:" ) ) ; out . newLine ( ) ;

Fix:
FileWriter fw = new FileWriter ( "debug//attribute_changes.txt" ) ;