Shown in the UK on TV in the early 80s about a US geek teenager who is a social outcast and lives his entire life by a (fictional) book called (Corak?). Nothing to do with Tarzan.
This Corak is a space traveller, and long readings from his book intersperse the movie.
As an example the kid invents a gizmo that locks the reels of a fruit machine to a win position.
The book "Corak?" is the fantasy, and long passages are read throughout the film. In the end the kid dies and the book's traveller bemoans the emptiness of space.
Possibly a 60s/70's movie and American origin.