Added output if no input is found.
Fixed indexing bug.
Removed double free.