bug fix

add a out.close() before rename.