add check for blank line in __do_substiutions method to avoid index out of bounds exception