Fixed array index error, out of bounds.
Removed extra newlines.
Simplified main.cpp