The only way to get the error message you described would be to attempt to echo the value of the file handle $openmaincont.
The code you posted should echo
<div id="content">
</div>
... and nothing more. None of the PHP that you posted actually outputs anything.
I don't see anything (other than that) broken in your code, but if you use fopen, you should check to see that it succeeded before passing the handle to fread. If the file exists in the current directory and is readable, $maincont should contain its contents, which you would have to echo in order to output.
Here is a much simpler version:
<div id="content">
<? readfile('main.content') ?>
</div>