remove extra FileOutputStream variable and .flush() call