still need to check the date problem
fixed a possible back at out.close adding checking for null