How can we be sure the Old Testament is accurate if Elijah was the only prophet left? This morning in church the service was about Elijah with the Baal's prophets. I read this verse and some questions arose which I could not find an answer on. 


  1 Kings 18:22
  Then said Elijah unto the people, I, even I only, remain a prophet of the LORD; but Baal's prophets are four hundred and fifty men.


The following questions arose: 


Was the Bible already written in the time of Elijah?
If Elijah was the only prophet left, how can we make sure that the Baal's prophets did not corrupt the scriptures? And more in general, how can we make sure that none of the bad kings back in this time did not corrupt the scriptures?
Just because there was only one prophet does not mean there were no priests or followers - prophets were messengers from God, priests actually served in the Temple, and adherents, well, they adhered.  In Isaiah, the notion of the Remnant God's select people who remain true even when most fall away is well understood.

Additionally, it does not diminish the text for Elijah to have engaged in hyperbole.  Even most inerrantists can accept that a human feeling all alone might exclaim, "I'm the only one left!"

Finally, if you read the context of 1 Kings 18 - you find just a few verses up (1 Kings 18:1 - 15) an encounter in which Elijah speaks with a fellow servant of the Lord - Obadiah - who would qualify as part of the remnant. And, as @RyanFrame points out, in 1 Kings 19:18, God reminds Elijah that he has "7000 who have not bended the knee".

To answer the related questions:


Most scholars assume the books of the Torah to have been pretty well settled no later than 600 BC - and these events are less than 200 years away from that.  Beyond that, the JEPD theory would argue that an iteration of the text was done as early as 1000BC - and depending on how liberal or conservative one is, there were no changes to some oral retelling changes in that time.
Some historians like to state that Ba'al and El Shaddai / Yahweh were originally in one narrative together.  The preserved Old Testament doesn't seem to reference this in any way, but other local myths do.  This answer, in particular speaks to the Ugaritic and Cananite understandings of Ba'al, and his consort-like status to Yahweh. Theoretically, if the prophets of Ba'al had corrupted the Scriptures, they would have preserved the role of Ba'al. As it is, the only mentions of Ba'al are negative (disputing her actual existence) and as a misguided belief only.  That they did not would seem to suggest that the preserved text was not influenced by the surrounding nations.