I was playing around with some code for one of my client’s site and using the get_attachement_link.
The examples on the codex are pretty sparse right now and I was going to add my code snippet, but would prefer to get advice first.
The print "\n"; line isn’t absolutely necessary. Yeah, it’ll make your HTML markup look nicer when people use view-source, but it won’t affect the rendering of the page at all and any developer tool will reformat the markup anyway.
That said, this is pretty much the exact same code I use to look through attachments as well …