Moved outputstream to saveKey only. Closed input stream in constructor.