Implemented methods to actually perform the required task. Stuff left to do: add functionality to read line instead of string.