I would have to refer you to the Java® Tutorials (try the character streams section) about PrintWriter. Basically, you need to distinguish between writers and readers for characters (text‑based files) and bytes (non‑text files or binary files). Go through the whole Tutorials trail and that should explain everything.
You may be missing line ends because you are using \n which is the wrong line end for Windows®. Don't use \n even though you find it in many books. If you look through the PrintWriter ←link documentation you see it may not flush automatically even with \n. Use println instead of print.
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad: