Now using LINE_MAX and a switch statement. Also added support for ^G character