writeToTerminal method added