replace endl by '\n' to avoid flushing (increases performance)