Now handles blank lines and all memory leaks should have been taken care of