fixed correct handling and deletion of keys when taken from stdin