use output file instead of fileoutputstream