Fix memory leak. Reallocated input_str used for getline. Initialized structures.