Problem with sending and/or recieving data from Mega2560 to esp8266

Did you alter your ESP code also? If so could you please post it? You can remove the SoftwareSerial library from your above code. Also try adding a delay in the loop after the serial writes.