The name of the movie that fits your description is The Magic Book. The movie was about a young man who met a mysterious girl when he was writing a mysterious magic book. The girl provided him with inspiration and helped him become better at writing. However, when he discovered that this book was not an ordinary magic book, but a power that could control the fate of humans. While chasing after the spellbook. At the end of the movie, he tried to return it to humanity. However, when he tried to open the cover of the magic book, he found that the magic power in the book was beyond his control. He fell into madness and despair. In the end, the girl appeared in front of him and used her own power to protect the spellbook and help him regain control of his life. The heroine in the movie turned out to be her girlfriend in real life, which was also a highlight of the story.